如何删除集合中的最后一个模型?
if (this.Collection.models.length < newValue) {
console.log('adding');
this.Collection.models.add();
} else {
console.log('removing');
// this isnt working, by selecting it by the current collection array index
// basically this.Collection.remove([this.Collection.models.length-1])
//this.measuresCollection.models.get('beats').remove(this.measuresCollection.models[i].get('beats')[this.measuresCollection.models[i].get('beats').length]);
}
Run Code Online (Sandbox Code Playgroud)
我不知道id,所以我只想删除最后一个.
collection.pop([options])
Doc:Collection#pop.
它位于文档中的remove方法之下.它既可以删除最后一个模型,也可以在需要时将其返回给您.如果您只想删除它,请不要使用返回值.
| 归档时间: |
|
| 查看次数: |
1859 次 |
| 最近记录: |