1
我在重構我的應用程序,現在我的路由器不會響應。我覺得這可能與事件的順序有關。但那是猜測。有任何想法嗎?Marionette AppRouter未開火
init.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.js
define(function(require) {
'use strict';
var app = (require('app')()),
MainController = require('widgets/main/controller');
app.addInitializer(function() {
app.modules.main = new MainController();
});
});
部件/主/ 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!');
}
});
});