I am trying to debug someone else's UI implementation, and it is really hard at this point to know what events are calling which functions
.
Is there a way to know what function
was called when I trigger an event? Maybe with Firebug
?
I am trying to debug someone else's UI implementation, and it is really hard at this point to know what events are calling which functions
.
Is there a way to know what function
was called when I trigger an event? Maybe with Firebug
?
- Are the events attached to inspectable DOM elements? – Dagg Nabbit Commented Mar 12, 2012 at 3:11
- That is what I can't figure out. – Nic Hubbard Commented Mar 12, 2012 at 3:21
- How do you trigger the events? By clicking things, moving the mouse, etc? – Dagg Nabbit Commented Mar 12, 2012 at 3:22
- It is a click event, but I can't find a reference to what that is bound to. – Nic Hubbard Commented Mar 12, 2012 at 3:27
-
In that case it's probably bound to
window
ordocument
(assuming it happens when you click anywhere). I was going to suggest selecting the element and looking in the "Event Listeners" panel, but I guess that won't help. – Dagg Nabbit Commented Mar 12, 2012 at 3:36
3 Answers
Reset to default 4In chrome developer toolbar you can set event breakpoints. - hope this will help
There's an extension to Firebug called EventBug. There are actually quite a few extensions to Firebug that are awesome.
http://getfirebug./wiki/index.php/Firebug_Extensions#Eventbug
EventBug lets you see the event functions that are attached to an element and set breakpoints in their handlers.
You may also try to use Firebug's "Break on next" feature when in Script Tab. After enabling it, it will break whenever some script is going to be executed.
This however has a disadvantage that if you use a framework that is listening to mouse events globally (e.g. bound to <body>
), you will get a break point whenever you move your mouse, so then it's pletely useless.
Also, when there is some timeout set that fires before you manage to create your event (e.g. mouse click), the break will occur on that timeout.