0

I encountered the error I tried to use the reset method on one of my view's collection.

Here is its implementation

The collection:

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

The router file:

var cardsList = new Cards();
cardsList.fetch({success: function(){
    filteredCards = cardsList.where({Class: "ABC"}).concat(cardsList.where({Class: "ZYX"}));
    this.deckbuild = new Deckbuilder({collection:filteredCards});
}});

In my Deckbuilder view file I created another view within it using the same collection:

var cardselectView = new CardSelect({collection: this.collection});

Then in the CardSelect view file I wrote:

blahblah = new Collection();
this.collection.set(blahblah);

Then the error appeared. Is there anything wrong this my implementation? Did I violate some abstraction? I can no longer use any of Backbone's collection method on my collection object anymore.

1
  • 1
    where, findWhere and bunch of methods return array not an instance of Backbone.Collection Please refer back to Backbone doc… backbonejs.org Commented Sep 7, 2013 at 9:46

1 Answer 1

1

In the router file, collection passed to the Deckbuilder view is an array and not Backbone.Collection. Try making below change :

this.deckbuild = new Deckbuilder({collection: new Cards(filteredCards)});
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.