Frage

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?

War es hilfreich?

Lösung

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);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top