0

I experienced this error while adding "card = new Cards();" this specific code into my router file. This is the code for my router file.

var AppRouter = Backbone.Router.extend({
    routes: {
        "": "home",
        "build/:deck": "deckbuilder",
        "decks/:id": "deckviewer",
    },

    deckbuilder: function(decks){
        var cards = new Cards();
        this.deckbuild = new Deckbuilder();
        $('#content').html(this.deckbuild.el);
    }

});

My collection file is very simple.

window.Card = new Backbone.Model.extend({});
window.Cards = new Backbone.Collection.extend({
  model: Card,
  url: "/cards"
});

I've been trying to find out what's wrong but the error appeared immediately in my backbone.js vendor file. After looking at the trace, the error appeared after calling this line var cards = new Cards();. However, I don't know how to fix it.

1 Answer 1

7

Remove new from window.Card = new Backbone.Model.extend({}); and from window.Cards = new Backbone.Collection.extend({});.

You need use this:

window.Card = Backbone.Model.extend({});
window.Cards = Backbone.Collection.extend({});
Sign up to request clarification or add additional context in comments.

Comments

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.