0

I am reorganizing all my js introducing namespaces with a main script (using jQuery) :

var myapp : {
    user :   { ...  },  
    ...
    init : function() { ...}
}

and I load an additional js for some page like for example 'home.js', with :

(function(){
    $j.extend(true, myapp, { 
        _home : {
            init: function() { ...},        
            myfunc : function(prm){
                ...
            }
        }
    });
    myapp._home.init();
})();

Now, if I put a breakpoint in the myfunc function, and call myapp._home.myfunc(); in the console, Firebug doesn't hit.

Is it normal ? How can I have a breakpoint there ?

Edit: I am wrapping the _home script into a function.

2 Answers 2

0

Try using the "debugger" keyword

function test(variable) {
  for(var i=0; i<10; i++) {
    if(i == 5)
      debugger;
  }
}
5
  • But the myfunc is called (I added return "test"; to myfunc. and I get the "test" as a result of myfunc). Dec 4, 2012 at 9:53
  • we agree that you have activated your script-panel in firebug, right?
    – Flexo
    Dec 4, 2012 at 10:01
  • I am loading the additional script asynchronously. May it be an issue for Firebug ? (knowing that I can see the script _home.js in the script panel. Dec 4, 2012 at 10:13
  • Indeed that was due to the asynchronous load... If I load 'normally' (with <script src='home.js'></script>) I can see it and I can hit the breakpoint. Using my script to load asynchronously (home made), I can see the script in the panel but I can not hit breakpoints. Dec 4, 2012 at 10:24
  • Glad you figured it out :-)
    – Flexo
    Dec 4, 2012 at 10:59
0

Searching about asynchronous call and firebug issues, I found this thread

firebug (1.10.1) suggests javascript is not confined to a single thread in firefox (13.0)

which gives some details.

Conclusion : I will include my files in the 'traditional' way for debugging ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.