this.shipperModel = new shipperModel();
this.collection = new packetListCollection(this.options.packetData);
this.listenTo(this.collection, "change", this.render);
this.listenTo(this.collection, "add", this.render);
this.finalArry = [];
self.collection.each(function (modelData) {
self.shipperModel.fetch({
data: {
facility_id: modelData.facility_id ? modelData.facility_id : 0
}
}).then(function (response) {
console.log(response.records);
self.finalArry.push(response.records);
})
});
console.log(self.finalArry);
我的數組內骨幹模型總是即使是怎麼做的響應數據我確保結果得到所有上述取完成後,才顯示爲空白。取foreach循環
我正在獲取的模式是不相同的類型集合對不起我命名搞砸了的已經更新 – vini
好吧,我會回來秒一些示例代碼! –
@vini:我現在添加了一些示例代碼。我不認爲'async:false'是一個好主意。也許你可以像我在示例代碼中那樣做。對承諾的一般性閱讀不會受到傷害,因爲它真的很好知道! –