JavaScript triggers

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.


More in the discussion (powered by webmentions)

  • (no mentions, yet.)