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
Asked
Active
Viewed 4,114 times
6
-
http://stackoverflow.com/questions/10388199/backbone-js-collection-of-collections – Paul Hoenecke Apr 04 '13 at 05:15
-
i need to join two collection to each other – nAkhmedov Apr 04 '13 at 05:21
1 Answers
11
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)); });

Alex Curtis
- 5,659
- 3
- 28
- 31
-
You can add raw JSON data with the add method if you specified the [model](http://backbonejs.org/#Collection-model) attribute of your collection, so collectionA.add(collectionB) would work as long as collection is just a JSON object. – Loamhoof Apr 04 '13 at 07:54