0
votes

I have a very basic router to get things going, but I cant load Backbone.history.start() to start handling routes. jquery, underscore & backbone are loaded. Here's my basic router:

var AppRouter = Backbone.Router.extend({
    routes: {
        "*query": "defaultRoute"
    },

        initialize: function() {
            Backbone.history.start();
        },

        defaultRoute: function(query) {
            console.log(query);
        }
    });

var app_router = new AppRouter;

The error I'm getting is:

Uncaught TypeError: Object [object Object] has no method 'on' 

located in my backbone library file. Thanks in advance

2
The code you have posted above seems to be issue free. Check it out in this jsfiddle to see. I am still not sure exactly where you issue is coming from, but the error is indicating you are attempting to use the on method (coming from Backbone.Events) on an object that does not have it. If you post some more context/code maybe I can give you more information. - Andrew Terris

2 Answers

0
votes

Just a guess, can you move the Backbone.history.start(); code outside the Router creation? Basically put it after you fully bootstrap your application, like this:

$(function(){
  new AppRouter();
  Backbone.history.start();
});
0
votes

Late to this party, but the problem is likely in the 'events' property of the current view, which should contain an object with interface event mappings: http://backbonejs.org/#View.