1

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?

2
  • 1
    You can start by making your question a little clearer...maybe a little more context? Commented Dec 7, 2011 at 14:56
  • 2
    Yes how exactly are you calling "bindAll"? It takes more than one parameter. Commented Dec 7, 2011 at 15:00

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.