I have a backbone router that uses require js. Everything seems fine to me but it isnt working. I am calling router from my app.js:
Router JS:
define([
'jquery',
'underscore',
'backbone',
'view/questions/index'
], function($, _, Backbone, IndexView){
var AppRouter = Backbone.Router.extend({
routes: {
'/': 'index'
}
});
var initialize = function(){
var app_router = new AppRouter();
// Index Route
app_router.on('index', function(){
var indexView = new IndexView();
console.log('test');
indexView.initialize();
});
// Default Route
app_router.on('defaultAction', function(actions){
console.log('No Route', actions);
});
Backbone.history.start();
};
return {
initialize: initialize
};
});
App JS:
define([
'jquery',
'underscore',
'backbone',
'router'
], function($, _, Backbone, Router){
var initialize = function(){
Router.initialize();
};
return {
initialize: initialize
};
});
Guys I actually got this working. Here is the changes I made in the code.
And Here: