collection.reduce

reduce (foldl, inject)

collection.push

pushcollection.push(model, [options]) Add a model at the end of a collection. Takes the same options as add.

collection.pop

popcollection.pop([options]) Remove and return the last model from a collection. Takes the same options as remove.

collection.pluck

pluckcollection.pluck(attribute) Pluck an attribute from each model in the collection. Equivalent to calling map and returning a single attribute from the iterator. var stooges = new Backbone.Collection([ {name: "Curly"}, {name: "Larry"}, {name: "Moe"} ]); var names = stooges.pluck("name"); alert(JSON.stringify(names));

collection.partition

partition

collection.parse

parsecollection.parse(response, options) parse is called by Backbone whenever a collection's models are returned by the server, in fetch. The function is passed the raw response object, and should return the array of model attributes to be added to the collection. The default implementation is a no-op, simply passing through the JSON response. Override this if you need to work with a preexisting API, or better namespace your responses. var Tweets = Backbone.Collection.extend({ // The Twitt

collection.models

modelscollection.models Raw access to the JavaScript array of models inside of the collection. Usually you'll want to use get, at, or the Underscore methods to access model objects, but occasionally a direct reference to the array is desired.

collection.modelId

modelIdcollection.modelId(attrs) Override this method to return the value the collection will use to identify a model given its attributes. Useful for combining models from multiple tables with different idAttribute values into a single collection. By default returns the value of the attributes' idAttribute from the collection's model class or failing that, id. If your collection uses a model factory and those models have an idAttribute other than id you must override this method. var Lib

collection.model

modelcollection.model([attrs], [options]) Override this property to specify the model class that the collection contains. If defined, you can pass raw attributes objects (and arrays) to add, create, and reset, and the attributes will be converted into a model of the proper type. var Library = Backbone.Collection.extend({ model: Book }); A collection can also contain polymorphic models by overriding this property with a constructor that returns a model. var Library = Backbone.Collectio

collection.min

min