最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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

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

Share Improve this question asked Jun 14, 2013 at 14:20 Andrew MadonnaAndrew Madonna 1555 silver badges12 bronze badges 3
  • 3 lose the new in var AppRouter = new Backbone.Router.extend({... – Andbdrew 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(); – Dmitry Manannikov 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. – Andrew Madonna Commented Jun 14, 2013 at 14:25
Add a comment  | 

1 Answer 1

Reset to default 25

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

发布评论

评论列表(0)

  1. 暂无评论