【发布时间】:2013-02-19 16:46:06
【问题描述】:
我想知道这里的最佳模式/方法。这是我的路由器中的一个功能,因此用户点击“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]
}));
}
【问题讨论】:
标签: backbone.js