-
-
Save pward123/9673833 to your computer and use it in GitHub Desktop.
getFormValues
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
/** | |
* Returns a hash of the form values for the form closest to the provided target | |
**/ | |
getFormValues = function _getFormValues(target) { | |
var fields = $(target).closest('form').find(':input'); | |
return _.reduce(fields, function(initial, field) { | |
var name = field.name; | |
if (name === '') return initial; | |
initial[name] = field.value.trim(); | |
return initial; | |
},{}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment