Created
April 9, 2013 20:10
-
-
Save fourcolors/5348956 to your computer and use it in GitHub Desktop.
Allow nested attributes on 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
# Example usage | |
# @model.setNestedAttribute parent: 'foo', property: 'bar', value: 'catz', silent: true | |
setNestedAttribute: (options) -> | |
parent = options.parent | |
value = options.value | |
property = options.property | |
silent = options.silent | |
date_data = @get(parent) || {} | |
date_data[property] = value | |
@set(parent, date_data, {silent: silent}) | |
console.log date_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment