I need to clone the models in one backbone collection and add then add them to another. (IOW all of the models in the new collection need to be unique, and have no connection to the models in the original collection.)
Here is my code:
collection1.each(function( model ) {
var clone = new Backbone.Model( model.toJSON() );
clone.set( this.idAttribute, null, { silent: true });
collection2.add( clone );
});
This doesn't quite work. I can only add a model from collection1 to collection2 once. If I try to do it a second time, it fails. So somehow Backbone is detecting a dup.
Any suggestions on what I am doing wrong?
Thanks (in advance) for your help
collection2 = collection1.clone();
? – jakee