我有一个包含模型集合的集合。在提交给服务器之前,我必须获取每个模型并设置更多属性。
如何使用骨干网做这件事。?
更新:
这就是我试图打印模型的情况,如果它打印出来想尝试使用模型的set
属性,但是它给了我uncaught typeerror cannot call method 'each' of undefined
:
covertInvestmentJournal:function(){
this.investmentTransactionsCollection.each(function(model){
console.log(model);
});
}
答案 0 :(得分:0)
这就是我解决问题的方法:
for (var i = 0, l = investmentTransactionsCollection.length; i < l; i++) {
investmentTransactionsCollection.models[i].set({securityName:$('#security-name').val()});
investmentTransactionsCollection.models[i].set({valueDate:DateUtils.formatAsYMD($('#value-date'))});
investmentTransactionsCollection.models[i].set({adjustmentType:$('#adjustment-type').val()});
investmentTransactionsCollection.models[i].set({assetClass:$('#assetclass').val()});
investmentTransactionsCollection.models[i].set({currency:$('#currency').val()});
}