mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-24 14:27:56 -05:00
Added Backbone.Collection.toJSON. Returns array of model's toJSON
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user