Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 920
Andrew Madonna Avatar asked Jun 14 '13 14:06

Andrew Madonna


1 Answers

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

like image 92
Andbdrew Avatar answered Nov 15 '22 03:11

Andbdrew