我試圖通過獲取骨幹來初始化集合,我有這個在我看來:Backbone.js獲取集合沒有設置模型值?
initialize: function()
{
_.bindAll(this, 'render', 'addItem', 'appendItem');
this.collection = new MembersCollection();
this.collection.bind('add', this.appendItem);
this.collection.fetch({success: _.bind(function(blah)
{
console.log(blah);
this.render();
}, this)});
}
這似乎是工作,我得到一個成功的響應,正確數量的模型,它爲每個模型呈現正確數量的視圖,但是,如果我檢查model.attribute值,它只包含我的默認值,並且沒有來自服務器的值?
如果我檢查我的JSON響應,我確實在那裏看到正確的數據,有什麼我可能錯過了需要獲取數據設置?
我可以有你的JSON收集數據嗎?爲'fetch'方法提供'success'和'error'回調以查看被調用的內容。 – Deeptechtons 2012-07-09 05:00:14
你可以發佈你的收藏和模型代碼。可能聽起來很愚蠢,但是你是否在你的收藏中引用了你的模型?你發佈的代碼越多,我們就越容易提供幫助。 – TYRONEMICHAEL 2012-07-09 09:01:57