我在想这里最好的模式/方法。这是我的路由器中的一个功能,所以用户点击'quotes /:id',但为了呈现该视图,我需要他们的项目,客户和货币的列表。尝试实例化quotesEdit
视图之前,确保全部3次抓取()都已发生的最佳方法是什么?在用户点击某些内容时抓取所有信息被认为是不好的做法?主干 - 在渲染视图之前执行多个获取()()
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]
}));
}
那是行得通的吗?如果是这样的话,那就太好了! – benhowdle89 2013-02-19 17:02:04
@ benhowdle89,oughta工作。 – jevakallio 2013-02-19 17:03:05
默认情况下,使用'GET' http方法进行提取。我非常惊讶,我可以编写'_.invoke([quotes,projects,currency],'fetch',{type:'POST'})' – lexeme 2013-05-24 05:51:22