8

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

3
  • 3
    lose the new in var AppRouter = new Backbone.Router.extend({... Commented Jun 14, 2013 at 14:21
  • Change var AppRouter = new Backbone.Router.extend({ to var AppRouter = Backbone.Router.extend({ and change var appRouter = new AppRouter; to var appRouter = new AppRouter(); Commented Jun 14, 2013 at 14:23
  • @Andbdrew you are correct! :) I feel a little stupid, it must of creeped in there during the file move. Commented Jun 14, 2013 at 14:25

1 Answer 1

25

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

Sign up to request clarification or add additional context in comments.

1 Comment

hehe damn easy to miss!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.