在我的 Backbone 应用程序中,我正在制作一个 Web 应用程序,其中包含导航和页脚,通过适当地单击导航栏,我正在将新内容加载到主视图。
当我的初始页面加载时,我正在显示导航栏视图,并使用以下命令重定向到仪表板:
var naviView = Backbone.View.extend({
el:$("body"),
initialize:function(){
this.$el.find("nav").append(this.template); // showing navigation
APP.router.navigate("#/dashBoard/"); // redirecting to show main dashboard view
}
});
它工作正常,但我的问题是,每当我用新视图(仪表板视图)刷新时,导航栏就会消失。无需刷新一切正常,我可以单击任何链接导航新路由器。
因此,如何保持导航栏或页脚栏对所有视图可用,包括刷新页面,并记住最终单击的链接。
这是我的路由器:
var appRouters = Backbone.Router.extend({
routes:{
"":"loginPageProcess",
"initiate/":"initiate",
"dashBoard/":"dashBoard",
"myTask/":"myTask",
"repositories/":"repositories",
"saved-searches/":"savedSearches",
"favourites/":"favourites",
"reports/":"reports",
"preferences/":"preferences"
},
initialize:function(){
this.spaceHold();
},
initiate:function(){
this.spaceHold();
var x = new naviView();
},
loginPageProcess:function(){
this.spaceHold();
new loginView();
},
spaceHold:function(){
$("div.contentwrapper").empty();
},
dashBoard:function(){
this.spaceHold();
new dBView();
},
myTask:function(){
this.spaceHold();
new myTaskView();
}
});
任何人帮助我..?
提前致谢。