How can we know which javascript method is called and where it is defined? (When methods are attached dynamically)
Let us consider situation where JQuery Bind method is used to bind an event.
If I see control in FireBug with FireQuery, I can see events=Object{click =} handle=function()
But I don't know which method is attached with click event.
Is there any way to detect this method is being called from this file?
For 3-4 files, I could search. but for large number of files with heavy code, it is difficult to search.
views:
73answers:
3
+1
A:
You can use console.trace()
but this only works within the function
You may also find the question and answer here useful: http://stackoverflow.com/questions/3288222/what-events-are-bound/3288243#3288243
balupton
2010-07-19 10:01:50
If I know the function then I can put breakpoint. I know only control and need to know about associated methods.
Brij
2010-07-19 10:09:53
In webkit you inspect a element and see the attached events and their scope/definition. Whether this is in Firebug I am unsure. Otherwise you will just have to browse and add breakpoints, or put the browser into a pause and step through mode. Alternatively instead of inspecting the element, you could do this by clicking pause on the javascript, then clicking the button you want, then you'll break at what is fired and you can step through.
balupton
2010-07-19 10:18:30
The answer here may also help:http://stackoverflow.com/questions/3288222/what-events-are-bound/3288243#3288243
balupton
2010-07-20 09:18:03
+1
A:
You should be able to click on the "function()" and firebug 1.6 will navigate to the source.
johnjbarton
2010-07-19 20:35:07
+1
A:
just mouseover the event handler function in firebug
(if fireQuery
is installed)
Ninja Dude
2010-07-19 20:35:08