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集合中