I think I am missing some of the fundamentals about Backbone routing functions.
I am creating an application and it looks something like this:
file: app.js
App = {} App.nav = new Backbone.Router; require('app/controller');
file: controller.js
App.nav.route('home', 'home', function () { console.log("Home Activated"); }); App.navigate('home');
At this point, the browser changes the URL in the address bar to /home
, but nothing happens and I do not receive the Home Activated
console message.
I tried using my own routing class (i.e. Backbone.Router.extend({})
), but I really don't see the point, since I still need to initialize it, and I want to use central history / navigation in your application, that all modules / controllers add routing to it, and do not create a router for each controller.
What am I doing wrong?
source share