A List Apart has an article by PPK on
JavaScript triggers where he explains his way of making JavaScript
unobtrusive. He says, with a certain degree of accuracy, that using the
class attribute as a hook is somewhat limiting. His approach, however,
is to create brand new attributes, and then solve the “but it doesn’t
validate!” problem by running your own validator. Paul over at
paranoidfish expresses my view better than I could when he says “it
also seems that the suggested solution is significantly more complicated
and harder to maintain than the setup it was intended to improve upon“.
I’ve used non-standard attributes a few times, and sometimes there’s no
way around them. When I do it, though, I’m conscious that it’s a hack,
not a good approach. Perhaps in an XHTML world
this sort of thing is more reasonable, but this ain’t an
XHTML world—IE doesn’t interpret your
XHTML as XML, for a start.
JavaScript triggers
I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing
and articles. You can take a look at some projects I've worked on and
some of my writing. If you'd like to talk about your upcoming project,
do get in touch.