2

Is there a way to gather more information about the changes from within the Backbone.JS collection change event. What I would like to figure out is whether or not it possible to to know what the collection change was; was a model updated, was one added or removed from the collection and also, for every of these, figure out which one.

titel
  • 3,454
  • 9
  • 45
  • 54

1 Answers1

0

Different events

When model is added to collection

collection.on('add',this.someFunc,this);

When a model is removed from a collection.

collection.on('remove',this.someFunc,this);

There is no change event on collection but you need to listen on models change event for change

in model:

initialize:function(){
  this.on('change',function(){
  this.collection.trigger('change');
});
}

Now on collection you can hear for change event

collection.on('change',this.someFunc,this);

refer this for list of all backbone built-in events

StateLess
  • 5,344
  • 3
  • 20
  • 29