I am new trying to make use Routers in backbone but my Backbone.history.start() method does not work. It gives me below error
Uncaught TypeError: Cannot call method 'start' of undefined
Here is my code
(function ($) {
window.App = {
Models: {},
Collections: {},
Views: {},
Router: {}
};
window.Template = function (id) {
return _.template( $('#' + id).html() );
};
App.Router = Backbone.Router.extend({
routers: {
'': 'index'
},
index: function () {
console.log('index page');
}
});
var r = new App.Router;
Backbone.history.start();
})(jQuery);
How can I remove this error?
It happens because you do not have any
routesin your Router.You have
routersand it’s not the same 🙂