Skip to content

Instantly share code, notes, and snippets.

@jslatts
Created August 30, 2012 14:27
Show Gist options
  • Save jslatts/3529602 to your computer and use it in GitHub Desktop.
Save jslatts/3529602 to your computer and use it in GitHub Desktop.
Underscore/backbone this binding question
<snip>
initialize: function() {
_.bindAll(this, 'addEvent', 'render');
this.eventFeed = this.options.eventFeed;
this.eventFeed.on('add', this.addEvent);
},
render: function() {
$.get('/views/jsondata', function(data) {
var newModel = new models.SomeModel(data);
this.eventFeed.add(newModel);
});
},
addEvent: function(e) {
//Stuff
}
</snip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment