occasionally useful ruby, ubuntu, etc


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:


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.


Comments (2) Trackbacks (0)
  1. Have a look at http://firequery.binaryage.com, it displays events as an attribute in firebug’s HTML view.

  2. 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.

Leave a comment

No trackbacks yet.