Created
March 3, 2013 16:14
-
-
Save CoralineAda/5076709 to your computer and use it in GitHub Desktop.
Save only certain attributes in a Backbone model
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
MyApp.Foo = Backbone.Model.extend( | |
urlRoot: '/foos' | |
defaults: | |
attrs_to_sync: ['name', 'points'] | |
toJSON: (options) -> | |
attr = _.clone(@attributes) | |
json = new Object | |
_(@get('attrs_to_sync')).each (k) -> | |
json[k] = attr[k] | |
json | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment