在我的主干应用程序中,我正在制作一个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
}
});它工作得很好,但我的问题是,每当我用新视图(dashBoard视图)刷新时,导航栏就会熄灭。没有刷新所有工作都很好,我可以点击任何链接来导航新路由器。
那么,如何保持导航栏或页脚栏对所有视图都可用,包括刷新页面,并记住最后单击的链接。
这是我的路由器:
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();
}
});有谁能帮我吗?
提前谢谢。
发布于 2013-06-03 19:52:56
我在这里找到了这个问题的答案:Need help understanding the basics of nested views in backbone
谢谢大家..
https://stackoverflow.com/questions/16871383
复制相似问题