Created
November 2, 2016 22:39
-
-
Save Zaggen/87691a65d0c2d777b89a6312462844c8 to your computer and use it in GitHub Desktop.
Helper to append json data to a form Data
This file contains hidden or 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
helper = { | |
populateFormData: (formData, populationData)-> | |
@_iterativePush(formData, populationData); | |
return formData | |
_iterativePush: (formData, v, k = '')-> | |
if _.isObject(v) | |
_.each v, (v, innerK)=> | |
@_iterativePush(formData, v, "#{k}[#{innerK}]") | |
else | |
formData.append(k, v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment