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에서 컬렉션에 모델을 추가 할 수없는 이유