Created
July 29, 2011 10:34
-
-
Save bjrn/1113589 to your computer and use it in GitHub Desktop.
Zepto version of $.fn.serializeForm used in http://maccman.github.com/spine.tutorials/form.html. Requires Zepto > 0.6 that $.fn.serializeArray()...
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
// jQuery version of the same function. | |
// Zepto doesn't provide $.each, but rather uses the native Array.forEach() function | |
$.fn.serializeForm = function(){ | |
var result = {}; | |
$.each($(this).serializeArray(), function(i, item){ | |
result[item.name] = item.value; | |
}); | |
return result; | |
}; |
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
$.fn.serializeForm = function(){ | |
var result = {}; | |
$(this).serializeArray().forEach(function(item, i){ | |
if (item.name.length){ | |
result[item.name] = item.value; | |
} | |
}); | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment