Add a serializeObject jQuery funtion
This commit is contained in:
parent
ad0432f3be
commit
48913767d3
|
@ -42,11 +42,12 @@
|
|||
}
|
||||
})(console);
|
||||
|
||||
/* Get class list */
|
||||
/* jQuery Plugins */
|
||||
(function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/* Get class list */
|
||||
$.fn.classes = function (callback) {
|
||||
|
||||
var classes = [];
|
||||
|
@ -73,4 +74,22 @@
|
|||
return classes;
|
||||
};
|
||||
|
||||
/* Serialize form elements to an object */
|
||||
$.fn.serializeObject = function()
|
||||
{
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
$.each(a, function() {
|
||||
if (o[this.name] !== undefined) {
|
||||
if (!o[this.name].push) {
|
||||
o[this.name] = [o[this.name]];
|
||||
}
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
o[this.name] = this.value || '';
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
|
Loading…
Reference in New Issue