Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add collection to another collection in Backbone

i`ve an object collection. The problem is that add the object collection to another collection in Backbone.Push and add methods of Bacbone.Collection don't work.here is my collection which is need to be added to another collection

it is object collection

like image 203
nAkhmedov Avatar asked Apr 04 '13 05:04

nAkhmedov


1 Answers

Assuming they are backbone collections (which they don't look like in your console window)

try: collectionA.add(collectionB.models)

If you are trying to add an object array to a collection try this:

_.each(kids.result, function(kid){ collectionA.add(new Backbone.Model(kid)); });
like image 129
Alex Curtis Avatar answered Nov 14 '22 22:11

Alex Curtis