mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-01 08:19:38 +01:00
0ca1e83f76
git-svn-id: http://svn.automattic.com/wordpress/trunk@16022 1a063a9b-81f0-0310-95a4-ce76da25c4cd
32 lines
783 B
JavaScript
32 lines
783 B
JavaScript
/*!
|
|
* jQuery serializeObject - v0.2 - 1/20/2010
|
|
* http://benalman.com/projects/jquery-misc-plugins/
|
|
*
|
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
|
* Dual licensed under the MIT and GPL licenses.
|
|
* http://benalman.com/about/license/
|
|
*/
|
|
|
|
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
|
|
// serializes a form into an (arguably more useful) object.
|
|
|
|
(function($,undefined){
|
|
'$:nomunge'; // Used by YUI compressor.
|
|
|
|
$.fn.serializeObject = function(){
|
|
var obj = {};
|
|
|
|
$.each( this.serializeArray(), function(i,o){
|
|
var n = o.name,
|
|
v = o.value;
|
|
|
|
obj[n] = obj[n] === undefined ? v
|
|
: $.isArray( obj[n] ) ? obj[n].concat( v )
|
|
: [ obj[n], v ];
|
|
});
|
|
|
|
return obj;
|
|
};
|
|
|
|
})(jQuery);
|