0
從模型特定屬性我用下面的代碼取在Backbone.js的
_.each(cardIds, function(id){
var mdc = new MdlCard({cardId: parseInt(id)});
mdc.fetch({data:{cardId: parseInt(id)}});
cards.reset(mdc);
});
cardIds提取數據包含CardId中的特定列表。在我的卡片視圖中
initialize: function(){
_.bindAll(this,'render');
this.model.bind('change', this.render, this);
this.model.bind('destroy', this.remove, this);
},
render: function() {
var res = {data: this.model.toJSON(),ccId: this.model.cid}; $(this.el).html(this.template(res));
chkIds = this.model.get('checklists');
return this;
},
我將此卡模型傳遞給模板。但它會取兩個每一個請求對象 第一對象包含在從DB製作卡的型號和第二,當我寫這行chkIds = this.model.get('checklists');
這我定義(這實際上是我想要的)
但默認值將返回什麼。請幫我找到這個代碼中的問題。