我正在重构我的应用程序,现在我的路由器没有响应。我觉得这可能与事件的顺序有关。但那是猜测。有任何想法吗?
初始化.js
define(function(require) {
'use strict';
var app = (require('app')()),
Backbone = require('backbone');
app.modules = {};
require('modules/main/main');
app.on('initialize:after', function() {
if (Backbone.history) {
Backbone.history.start();
}
});
app.start();
});
模块/main/main.js
define(function(require) {
'use strict';
var app = (require('app')()),
MainController = require('widgets/main/controller');
app.addInitializer(function() {
app.modules.main = new MainController();
});
});
小部件/main/controller.js
define(function(require) {
'use strict';
var app = (require('app')()),
Marionette = require('marionette'),
View = require('./view');
return Marionette.Controller.extend({
initialize: function(options) {
this.router = new Marionette.AppRouter.extend({
appRoutes: {'apps': 'showApp'},
controller: this
});
},
showApp: function() {
console.log('route fired!');
}
});
});