Search code examples
jqueryasynchronousnamespacesfirebugbreakpoints

Firebug doesn't hit breakpoint in a function within a namespace


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.


Solution

  • Try using the "debugger" keyword

    function test(variable) {
      for(var i=0; i<10; i++) {
        if(i == 5)
          debugger;
      }
    }