Pergunta

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?

Foi útil?

Solução

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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top