Created
July 17, 2013 22:51
-
-
Save ryoppy/6025254 to your computer and use it in GitHub Desktop.
serializeArrayをname:valueのオブジェクトに変換 ref: http://qiita.com/ryoppy@github/items/0ceb0c19b92da34c7ce1
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
/** | |
* $formのデータをkey:valueで取得 | |
* @param {jQuery} $form | |
* @return {Object} {name: "value", ...} | |
*/ | |
getValues: function($form) { | |
return _.chain($form.serializeArray()) | |
.map(function(obj) { return [obj.name, obj.value] }) | |
.object() | |
.value(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment