Backbone.js 木偶路由/初始配置
我用以下方式设置了我的应用程序。它不允许我触发任何“java脚本路由”——在加载页面之后——在我导航到此页面并将子域扩展名添加到我输入的url之后Backbone.js 木偶路由/初始配置,backbone.js,marionette,Backbone.js,Marionette,我用以下方式设置了我的应用程序。它不允许我触发任何“java脚本路由”——在加载页面之后——在我导航到此页面并将子域扩展名添加到我输入的url之后 //Create App App = new Backbone.Marionette.Application(); //APP Regions App.addRegions({ displayRegion: "#displayRegion" }); //Routing controller someController = { u
//Create App
App = new Backbone.Marionette.Application();
//APP Regions
App.addRegions({
displayRegion: "#displayRegion"
});
//Routing controller
someController = {
usersarea: function () {
App.displayRegion.show(userList_ITEM);
alert('Users');
},
login: function () {
App.displayRegion.show(login_view);
alert('Login View');
}
};
//Router
MyRouter = new Marionette.AppRouter({
controller: someController,
appRoutes: {
"users": "usersarea",
"login": "login",
}
});//MyRouter
// Application Views
userList_ITEM_proto = Backbone.Marionette.ItemView.extend({
template: "#userList_ITEM"
});
login_view_proto = Backbone.Marionette.ItemView.extend({
template: "#login_view"
});
//Before STARTS
App.on('initialize:before', function () {
if (!Backbone.History.started) Backbone.history.start();
alert('It works');
login_view = new login_view_proto;
userList_ITEM = new userList_ITEM_proto;
});
//After START
App.on('initialize:after', function (options) {
console.log('Initialization Finished');
});
//At Start
App.on('start', function (options) {
alert('It works');
});
App.start();
在实例化视图实例之前,您正在尝试使用
someController
中的视图实例
这个脚本中有很多依赖性问题,应该考虑使用木偶的模块或Real.js来管理它们。
你的问题到底是什么?*当我导航到LoalHoal/Hub/用户时,所有的东西都是完美的,但是如果我进入子域,路由器就不能工作了。如果我是从这个url INITALU进入这个网站的话,那么什么都不会发生。。即使在我尝试其他URL时,如果您将其移动到App.displayRegion.show(…)
,您的警报也会被触发?