0

我有一个包含模型集合的集合。在提交到服务器之前,我必须获取每个模型并为其设置更多属性。

如何使用骨干做到这一点。?

更新 :

这就是我尝试打印的模型,如果它打印想要尝试使用set模型的属性,但它给了我uncaught typeerror cannot call method 'each' of undefined

covertInvestmentJournal:function(){
            this.investmentTransactionsCollection.each(function(model){
                  console.log(model); 
                });
        }
4

1 回答 1

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()});
            }
于 2013-07-15T11:58:44.550 回答