Created
June 4, 2013 16:51
-
-
Save wbbradley/5707555 to your computer and use it in GitHub Desktop.
How to munge Backbone.Model data before sync
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
class MyModel extends Backbone.Model | |
sync: (method, model, options) => | |
console.log 'MyModel : info : trying to coerce property_X to be property_Y when pushed to server' | |
if method in ['create', 'update', 'patch'] | |
options.attrs = @toJSON(options) | |
options.attrs.property_Y = @get('property_X') | |
delete options.attrs.property_X | |
super | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment