Trying to get a backbone router to work. Having one of those situations where nothing is happening so its difficult to pinpoint the problem.
Is there a way to find out what the Router is actually receiving so that I can try to pinpoint the problem with my routes?
This is the code so far:
// ROUTER
var TheRouter = Backbone.Router.extend({
// ROUTES
routes: {
"": "main",
"/route1/:key": "route1"
},
// INITIALIZE
initialize: function() {
_.bindAll(this);
},
// ROUTES
main: function(){
alert('main');
},
route1: function(key){
alert(key);
}
});
// Create new router
var theRouter = new TheRouter();
// Start history
Backbone.history.start({pushState: true});
Thanks so much!
You can bind to the
routeevent on theBackbone.history. According to the source code you get all the info going into the router from that event, meaning you should be able toconsole.logit.