我在想這裏最好的模式/方法。這是我的路由器中的一個功能,所以用戶點擊'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