After about a year I'm getting re-acquainted with my old friend backbone. Working through this tutorial I'm puzzling over a couple of things. Namely that the view's initialize uses an underscore bindAll method to scope "this" to the render method:
var CountryView = Backbone.View.extend({
tagName: 'option',
initialize: function(){
_.bindAll(this, 'render');
},
render: function(){
this.$el.attr('value', this.model.get('id')).html(this.model.get('name'));
return this;
}
});
Here's a trivial js fiddle I'm working with that works. The line in question is line 13: http://jsfiddle.net/wrGX5/1/
From reading the documentation, it looks like the only difference between _.bind and _.bindAll is that bindAll will bind to multiple methods. If that's the case, why does _.bind(this, 'render') not do the same thing? line 13 of this fiddle: http://jsfiddle.net/4t3AX/1/ Is there something fundamentally different about the way _.bind it works other than the number of methods it will scope?
Side question: can you highlight specific lines in jsfiddle?