Last active
August 27, 2021 08:46
-
-
Save heeplr/b4ed41bbdf074a5c7f6ec77ece47df5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Model = BackboneModel.extend({ | |
/* list of read-only attributes */ | |
readOnly: [], | |
toJSON: function (options) { | |
/* convert attributes to JSON but omit the ones from "readOnly" */ | |
return _.clone( | |
return _.omit(BackboneModel.prototype.toJSON.apply(this), this.readOnly) | |
) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Might want to return
_.omit(BackboneModel.prototype.toJSON.apply(this), this.read_only)
._.clone
is not needed because_.omit
already creates a new object.