Added Backbone.Collection.toJSON. Returns array of model's toJSON

This commit is contained in:
Chris Pickett
2010-10-20 15:28:47 -04:00
parent c025904432
commit 89e7e6767f

View File

@@ -329,6 +329,11 @@
// The default model for a collection is just a **Backbone.Model**.
// This should be overridden in most cases.
model : Backbone.Model,
// Return a array containing each model's toJSON result.
toJSON : function() {
return this.models.map(function(model){ return model.toJSON(); })
},
// Add a model, or list of models to the set. Pass **silent** to avoid
// firing the `added` event for every new model.