我有以下一段代码
initialize : function(option){
//some code
this.PassedCollection = this.options.serverResponse.passedCollection;
this.NewCollection = new Collection();
this.NewSectionCollection.bind("add", this.add, this);
this.NewSectionCollection.bind("remove", this.remove, this);
//some code
}
//some other code
addRemove: function(){
this.PassedCollection.forEach(_.bind(function(passedModel){
if(passedModel.reference==event.target.id){
if($('input[name='+passedModel.reference+']').attr( 'checked')){
console.log("checked");
this.NewCollection.add(passedModel);
}
else{
console.log("unchecked");
this.NewCollection.remove(passedModel, {silent : true});
console.log(JSON.stringify(this.NewCollection));
}
}, this));
}
我可以将“passedModel”添加到 NewCollection,但不能删除它们。我做错了什么,我应该如何更正我的代码?