Last active
August 29, 2015 14:07
-
-
Save Rodrigora/18124bb513144a6ca4ef to your computer and use it in GitHub Desktop.
add support to array attributes to EmberJS models
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
DS.ArrayTransform = DS.Transform.extend | |
deserialize: (serialized)-> | |
if Ember.typeOf(serialized) == "array" | |
serialized | |
else | |
[] | |
serialize: (deserialized)-> | |
type = Ember.typeOf deserialized | |
if type is 'array' | |
deserialized | |
else if type == 'string' | |
deserialized.split(',').map (item) -> | |
jQuery.trim(item); | |
else | |
[] | |
PortfoliosApplication.register("transform:array", DS.ArrayTransform); | |
PortfoliosApplication.App = DS.Model.extend | |
availableSections: DS.attr('array') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment