Do you really need to output this data embedded in the HTML? Does it have any meaning/purpose without Javascript? There are two simple non- hackish ways you can do it:
1: load data later via XHR, use an element identifier to bind it 2: output metadata in the class attribute - it's valid, and not against the specification - the class attribute is not specifically meant for presentation, the specs say "For general purpose processing by user agents". ex: class="link { foo: 'bar', amp: 'bamp', x: [1,2,3] }". It's easy to create your own parser for that: $.fn.mdata = function(){ return window["eval"]("(" + this[0].className.match(/{.*}/) + ")"); }; $('a').mdata() == Object foo:'bar' etc.. It will work as long as you use valid JSON. cheers, Ricardo On Sep 22, 8:41 pm, WalterGR <walte...@gmail.com> wrote: > On Sep 22, 4:35 pm, Ricardo <ricardob...@gmail.com> wrote: > > > This doesn't make any sense. If you're already using jQuery why keep > > your handler in the HTML? > > Because I need to pass additional information to the event handler in > a clean way. (i.e. rather than hacks using various attributes on the > anchor.) Is there a non-hackish way to do this? > > Thanks for the code snippet - that's what I was looking for. > > Walter