いくつかの異なるオプションを備えたルーターがあります.1つのインスタンスでは、ルートの1つをロードする必要がありますが、これはうまく機能しますが、常に呼び出されるデフォルトルートはいくつかの追加テンプレートでロードされます.
この場合、このルートが CMS の場合、デフォルト ルートから要素をロードしないと言う方法があるかどうか疑問に思いました。
私のルーターからのコード:
define([
'jquery',
'underscore',
'backbone',
'views/common/header',
'views/common/menu',
'views/rightPanel',
'views/landing',
'views/personalBanking',
'views/currentAccounts',
'views/signIn',
'views/cms/cmsView',
], function($, _, Backbone, headerView, menuView, rightPanelView, landingView, personalBankingView, accountsView, signInView, CMS){
var AppRouter = Backbone.Router.extend({
currentView: null,
initialize: function() {
this.showView(headerView);
this.showView(menuView);
//TODO set for TV-width
if($(window).width() > 180) {
this.showView(rightPanelView);
}
},
routes: {
'': 'defaultAction',
'personal': 'showPersonalBankingView',
'accounts': 'showCurrentAccountsView',
'signIn': 'showSignInView',
'CMS': 'CMSView',
},
defaultAction: function(actions){
this.showView(landingView);
},
showPersonalBankingView: function(actions){
this.showView(personalBankingView);
},
showCurrentAccountsView: function(actions){
this.showView(accountsView);
},
showSignInView: function(actions){
this.showView(signInView);
},
CMSView: function(actions){
this.showView(CMS);
console.log("cms view going on");
},
showView: function(view) {
view.render();
if(view.postRender) {
view.postRender();
}
}
});
var initialize = function(){
new AppRouter();
Backbone.history.start();
};
return {
initialize: initialize
};
});
私が十分に詳細に説明していない場合は、バックボーンに非常に慣れていないため、さらに情報を求めてください。