Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making Firebug break inside dynamically loaded javascript

I'm looking for a way to debug a dynamically loaded jQuery document.ready function.

Obviously I can't just bring up the script panel and add a breakpoint with the mouse since the function does not exist there.

I've also tried adding "debugger;" to the function (without the quotes), but that did not do anything. I have ensured that the function is actually executed while I tried this.

Thanks for your help,

Adrian

Edit: I just noticed that Firebug actually breaks on debug. However, when it does so on a dynamically loaded script, it does not bring up the source code of that script as usual. Plus, the call stack ends right below my own code. I can bring up the implementation for document.ready via the call stack, but that does not really help. Is this a Firebug bug or have I missed something?

like image 732
Adrian Grigore Avatar asked May 13 '09 15:05

Adrian Grigore


1 Answers

I just worked on this similar question. The solution involves adding the word debugger twice; once at the top of the external file and one more time at the top of the function that needs to be debugged.

I noticed that if the debugger word was used only once, it did not work. Example:

//myExternal.js
debugger;
function myExternalFunction(){
 debugger;
 /* do something here */
}
like image 129
Jose Basilio Avatar answered Nov 07 '22 15:11

Jose Basilio