Skip to content

Instantly share code, notes, and snippets.

@pward123
Forked from digilord/formGetter.coffee
Last active August 29, 2015 13:57
Show Gist options
  • Save pward123/9673833 to your computer and use it in GitHub Desktop.
Save pward123/9673833 to your computer and use it in GitHub Desktop.
getFormValues
/**
* 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