0
window.NCollection = Backbone.Collection.extend({
url: '/api/all',
model: N,
parse: function(data){
var that = this;
_.each(data, function(item){
switch(item.cat){
case 't1':
console.log(new Note(item));
that.add(new Type1(item));
break;
case 't2':
that.add(new Type2(item));
break;
default:
that.add(new T(item));
}
});
},
nextOrder: function() {
if (!this.length) return 1;
return this.last().get('id') + 1;
},
});
为什么模型无法添加到集合中?在页面加载时我获取集合的数据。 但收集长度也是0.为什么模型无法添加到BackboneJS集合中