Skip to content

Instantly share code, notes, and snippets.

@chiefGui
Created June 2, 2015 19:44
Show Gist options
  • Save chiefGui/06ddabb2f666fd9b9508 to your computer and use it in GitHub Desktop.
Save chiefGui/06ddabb2f666fd9b9508 to your computer and use it in GitHub Desktop.
Implementation of a deep cloning method into a Backbone.Collection
var Users = Backbone.Collection.extend({
clone: function (deep) {
if (deep) {
return new this.constructor(_.map(this.models, function (model) {
return model.clone();
}));
};
return Backbone.Collection.prototype.clone.apply(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment