collection.where

wherecollection.where(attributes)
Return an array of all the models in a collection that match the passed attributes. Useful for simple cases of filter.

var friends = new Backbone.Collection([
  {name: "Athos",      job: "Musketeer"},
  {name: "Porthos",    job: "Musketeer"},
  {name: "Aramis",     job: "Musketeer"},
  {name: "d'Artagnan", job: "Guard"},
]);

var musketeers = friends.where({job: "Musketeer"});

alert(musketeers.length);
doc_Backbone
2016-04-17 12:21:32
Comments
Leave a Comment

Please login to continue.