Andrew Madonna
Andrew Madonna

Reputation: 155

Backbone.js - Uncaught TypeError: Object [object Object] has no method 'apply'

I am new to Backbone.js. For experimenting / initial development, I had everything on one page in the tag, but I started separating out the code into a separate .js file. After I did that I get an error coming from the Router.

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

Here is my Router code:

       var AppRouter = new Backbone.Router.extend({
            routes: {
                ":uuid": "details"
            },
            details: function (uuid) {
                // load details
                new DetailView({id: uuid, el: $('#detailView')});
            }
        });

        var appRouter = new AppRouter;

I have the Models/Views loaded in a file tag above, but even if I comment out the file's tag or empty the file, it still displays thing error.

The line throwing the error is var appRouter = new AppRouter;

I'm I doing something wrong with the router code.

Thanks!! Andrew

Upvotes: 8

Views: 4040

Answers (1)

Andbdrew
Andbdrew

Reputation: 11895

Remove the new in var AppRouter = new Backbone.Router.extend({...

Upvotes: 25

Related Questions