digToGetWater
digToGetWater

Reputation: 171

Using Remove event to detect the model removed from the collection in Backbone.js

My question is , is there a way to detect the model that got removed from the collection when we bind/listen to the collection's add Event.

for ex:

this.listenTo(monthsOnBoardCollection, "remove", function(){
  //is it possible here to find what got removed from the collection ? 
}

Upvotes: 0

Views: 292

Answers (1)

iMoses
iMoses

Reputation: 4348

You have the Catalog of Events which shows the arguments being passes to the event.

"remove" (model, collection, options) — when a model is removed from a collection.

So it's basically:

this.listenTo(monthsOnBoardCollection, "remove", function(model, collection, options){
  //now you have the model, the collection and the options which were passed to the remove method
}

Upvotes: 2

Related Questions