History.start () function does not work in the spine
I'm a newbie trying to use Routers on the backbone but my method Backbone.history.start()
doesn't 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 do I remove this error?
+3
source to share
2 answers