I'm trying to have a model listen to a collection and fetch itself when the collection changes:
class Team extends Backbone.Model
urlRoot: '/team',
initialize: function(attributes, options) {
this.listenTo(members, 'change', this.fetch)
The fetch does seem to trigger, but the url is all messed up, and to get it to work I have to wrap it in an anonymous function:
this.listenTo(members, 'change', function() {this.fetch();})
Interestingly when I add a "test" function to the model and put this.fetch() inside it, it works:
this.listenTo(members, 'change', this.test)
test: function() {
this.fetch();
}
Why can't I just do this.fetch
inside the listenTo
?