• You need to use bla.init.bind(bla) or function(){bla.init()}, not just bla.init.

    It's one of the 'gotchas' of JavaScript, and it's the same thing that happens for setInterval, setTimeout, or any callback.

    Basically, when you call a function, like bla.init(), the this variable gets set up to bla. However, if you just pass bla.init, you're basically doing this:

    var x = bla.init;
    x();
    

    In that case, x is just a function, that has no association with bla at all - so when you call it, this isn't set.

About

Avatar for Gordon @Gordon started