1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
agendav_ynh/sources/web/public/js/libs/jquery.serializeobject.js
2014-01-07 17:53:08 +01:00

25 lines
674 B
JavaScript

$.fn.serializeObject = function()
{
var o = {};
var a = this.find(':input').serializeArray();
$.each(a, function() {
// Basic true/false translation
if (this.value == 'true') {
this.value = true;
} else if (this.value == 'false') {
this.value = false;
} else if (this.value === undefined) {
this.value = '';
}
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;
};