10Sep/092
Debugging unobtrusive javascript in jQuery
So if you work for a large enterprise website like I do, where each page loads dozens or hundreds of kilobytes of javascript, it can be hard to figure out exactly what happens when you click that div and something magically happens, due to the wonders of unobtrusive javascript.
Or, to rephrase the question, "I know how to add event handlers to an object -- how do I enumerate what's already been attached?"
And it's pretty easy, but unfortunately it doesn't use a public API. Anyway, try this in Firebug:
$("#the_button").data("events");
If there are any events on that element, they'll be displayed. The only drawback is...you have to know exactly which element the events are attached to, or guess around a bit.
Enjoy!
September 12th, 2009 - 03:57
Have a look at http://firequery.binaryage.com, it displays events as an attribute in firebug’s HTML view.
September 12th, 2009 - 08:48
Thanks — I’m a little leery of installing anything that might make Firebug even slower than it already is, but this looks like a good idea anyway.