Sha256: 1a316efeb397282020ec00a26f383d8639e57246d9e1bbb4fb7a7963facfc5fd
Contents?: true
Size: 1.55 KB
Versions: 20
Compression:
Stored size: 1.55 KB
Contents
# ----------------------------------------------------------------------------- # Author: Alexander Kravets <alex@slatestudio.com>, # Slate Studio (http://www.slatestudio.com) # # Coding Guide: # https://github.com/thoughtbot/guides/tree/master/style/coffeescript # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # RAILS FORM OBJECT PARSER # ----------------------------------------------------------------------------- # Get form data object from serialized form object, it uses special format for # object names for support of: # - files # - lists # - nested objects # # ----------------------------------------------------------------------------- @railsFormObjectParser = # PRIVATE =============================================== _parse_form_object: (serializedFormObject) -> formDataObject = new FormData() for attr_name, attr_value of serializedFormObject # special case for LIST inputs, values separated with comma if attr_name.indexOf('[__LIST__') > -1 attr_name = attr_name.replace('__LIST__', '') values = attr_value.split('|||') for value in values formDataObject.append("#{ @config.resource }#{ attr_name }[]", value) else # special case for FILE inputs if attr_name.startsWith('__FILE__') attr_name = attr_name.replace('__FILE__', '') formDataObject.append("#{ @config.resource }#{ attr_name }", attr_value) return formDataObject
Version data entries
20 entries across 20 versions & 1 rubygems