我想知道这里最好的模式/方法.这是我的路由器中的一个功能,因此用户点击'quotes /:id',但是要呈现该视图,我需要一个他们的项目,客户和货币的列表.在尝试实例化quotesEdit视图之前,确保所有3个fetches()都已发生的最佳方法是什么?当用户点击某些内容时,获取所有信息被认为是不好的做法吗?
quotesEdit: function(id) {
kf.Collections.quotes = kf.Collections.quotes || new kf.Collections.Quotes();
kf.Collections.projects = kf.Collections.projects || new kf.Collections.Projects();
kf.Collections.currencies = kf.Collections.currencies || new kf.Collections.Currencies();
//do a fetch() for the 3 above
kf.Collections.customers = kf.Collections.customers || new kf.Collections.Customers();
var quote = kf.Collections.quotes.where({Id: parseInt(id, 10)});
kf.Utils.ViewManager.swap('sectionPrimary', new kf.Views.section({
section: 'quotesEdit',
model: quote[0]
}));
}
Run Code Online (Sandbox Code Playgroud) backbone.js ×1