I am trying to start history with backbone however I get the error:
Cannot call method ‘start’ of undefined
Here is a link to the full code : http://pastebin.com/pNsYghgE
I have jquery, underscore, and backbone js include before this code so I would imagine this should work based off the documentation. I am using backbone 0.9.2. What am I doing wring here?
EDIT: ANSWER
I want not creating an instance of my routers so I added this code to before I called Backbone.history.start():
//initialize all routes
_(this.modules()).each(function(module, moduleName)
{
_(module.routers).each(function(router, routerName)
{
new router();
});
});
Backbone.historycan only be started after one or more routers have been defined with routes:http://backbonejs.org/docs/backbone.html#section-113
You can see here, that the
Backbone.historyobject is created when routes are defined. I don’t see any routers or routes being defined in the posted code, so I’m guessing that this is the problem.