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.
Asked
Active
Viewed 600 times
1

Brij
- 6,086
- 9
- 41
- 69
3 Answers
1
You can use console.trace()
but this only works within the function
You may also find the question and answer here useful: what events are bound?
-
If I know the function then I can put breakpoint. I know only control and need to know about associated methods. – Brij Jul 19 '10 at 10:09
-
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 Jul 19 '10 at 10:18
-
1The answer here may also help: http://stackoverflow.com/questions/3288222/what-events-are-bound/3288243#3288243 – balupton Jul 20 '10 at 09:18
1
You should be able to click on the "function()" and firebug 1.6 will navigate to the source.

johnjbarton
- 1,857
- 1
- 13
- 12
1
just mouseover the event handler function in firebug
(if fireQuery
is installed)