movieDb.Router = Backbone.Router.extend({
routes:{
'': 'landPage',
'home': 'landPage',
'login': 'login',
'signup': 'signup'
},
landPage: function(p){
$('div#homepage').empty();
},
login: function(p){
new loginViews(); // Calls its own model
},
signup: function(p){
new signupViews(); // Calls its own model
}
});
的問題是,從註冊來和呼叫登錄時,還調用以前的模型請求(註冊)導致登錄並在同一時間加入申請(我的模型是阿賈克斯請求),我如何在每次在視圖中創建新請求時刪除先前調用的模型。如何清潔視圖和模型在Backbonejs
謝謝。
但在這種情況下,我不能把沒有通話的具體意見(loginViews,signupViews)因此,去掉模型/清潔的觀點實際上將阻止打電話給那個觀點的模型,我已經檢查了你給我的最後一個鏈接,對於像我這樣的初學者來說,我覺得它有點複雜。 – Barry 2012-07-11 05:37:25
爲什麼不是 註冊:function(p){ window.signupModel = new SignupModel();新的signupViews({model:window.signupModel}); } – MarkKGreenway 2012-07-11 05:43:30
這與我的實現沒有什麼不同,只是我在視圖中不是從路由器調用模型,所以它不能解決它,謝謝 – Barry 2012-07-11 05:53:31