How to add a collection to another collection in Backbone

I collect the object. The problem is that adding a collection of objects to another collection in Backbone.Push and adding Bacbone.Collection methods do not work. Here is my collection to add to another collection.

it is object collection

+5
source share
1 answer

Assuming they are basic collections (which they don't look in the console window)

try: collectionA.add(collectionB.models)

If you are trying to add an array of objects to the collection, try the following:

_.each(kids.result, function(kid){ collectionA.add(new Backbone.Model(kid)); });
+8
source

All Articles