backbone-associations
backbone-associations copied to clipboard
Cloning populates the attributes from json which can contain remoteKey
Probably there is a reason for this implementation, but in case of a relation with a remoteKey the cloned model is not going to have the same attributes as the original.
clone: function (options) {
return new this.constructor(this.toJSON(options));
}
Also if toJSON is overridden for whatever reason, this clone method does not help. What's the reason to have this cloning instead of the Backbone's clone?
A workaround that worked for me is:
new MyModel(otherModel.attributes)