在我的代码中,当我从另一个页面再次返回主页面时,它无法在主区域内正确呈现(样式丢失)。就像go_to_main_page: function()
触发它时显示主页面但我无法获得模板中指定的原始样式。
var Page = new Marionette.Application();
Page.addRegions({
mainRegion: "#main-region"
});
Page.MainView = Marionette.ItemView.extend({
id: "main-view",
tagName: "div",
template: "#main-template",
events:{
"click #another_page": "go_to_another_page",
},
go_to_another_page: function(){
var anotherpageView = new Page.AnotherPageView();
Page.mainRegion.show(anotherpageView);
},
});
Page.AnotherPageView = Marionette.ItemView.extend({
id: "id_another_page_id",
tagName: "div",
template: "#anotherpage-template",
events:{
"click #main_page": "go_to_main_page"
},
go_to_main_page: function() {
var mainView = new Page.MainView();
Page.mainRegion.show(mainView);
}
});
Page.on("initialize:after", function(){
var mainView = new Page.MainView();
Page.mainRegion.show(mainView);
});
Page.start();