使用Remove事件检测从Backbone.js中的集合中删除的模型

时间:2013-04-01 18:15:45

标签: backbone.js underscore.js backbone.js-collections

我的问题是,当我们绑定/收听集合的add事件时,有没有办法检测从集合中删除的模型。

代表:

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

1 个答案:

答案 0 :(得分:2)

你有Catalog of Events,显示传递给事件的参数。

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

所以基本上是这样的:

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
}
相关问题