Question

After using _.bindAll('addOne'), the addOnemethod does get a correct this but it somehow breaks function calls on other objects inside this "bound" method :

/**
 * Add an element to the list
 */
addOne: function(tag) {

    // scope of this is correct
    var newClass = App.getViewClass('myClass')(someOptions) <-- scope inside App::getViewClass is wrong! overriden by current this

}

Any ideas on how i could somehow restore normal behavior?

Was it helpful?

Solution

Needed to wrap my getter :

var myObject = new (App.getModelClass(model))(data);

As i got incorrect scope with :

var myObject = new App.getModelClass(model)(data);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top