我有一个 Backbone.Pageable 集合,我正在尝试对其进行过滤,但并使用过滤后的值重置该集合,但在重置之后,collection.fullCollection 的模型比原始模型少一个。
这是我的收藏:
var todoCollection = Backbone.PageableCollection.extend({
mode:'client',
search: function(letters){
var self = this;
if(letters === "") return this.fullCollection.models;
var pattern = new RegExp(letters,"i");
return this.fullCollection.filter(function(data) {
return pattern.test(data.get("text"));
});
}
});
你可以在这里查看这个小提琴。