This tutorial suggests that we need to do _.bindAll
to get the correct value of this
in our functions. It seems that _.bindAll
is no longer required with Backbone. The following code logs the same thing twice:
var TestView = Backbone.View.extend({
initialize: function () { _.bindAll(this, 'func1'); },
func1: function () { console.log(this); },
func2: function () { console.log(this); }
});
var testView = new TestView();
testView.func1();
testView.func2();
Am I correct in assuming that bindAll
is no longer required, or am I just making a stupid mistake?