JAVASCRIPT
30
epp new
Guest on 29th April 2022 01:29:40 AM
(function($) {
$.fn.serializeFormJSON = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
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);
function call(id, method, args, callback) {
msg = {o: id, m: method, a: args};
return $.post(document.URL, JSON.stringify(msg), callback, "json");
}
function clearFormHelps(frmId) {
frm = $('#' + frmId);
frm.find(".help-block").html('');
frm.find(".form-group").removeClass('has-error');
}
function setErrorMessages(frmId, msgs) {
for (p in msgs) {
el = $('#' + frmId + '-' + p + '-info');
if (msgs[p].length > 0) {
console.log(el);
el.html(msgs[p]);
el.parent().closest('.form-group').addClass("has-error");
}
}
}
var bindPropertiesToText = function(obj, els) {
for (p in obj) {
console.log(p + ' -> ' + obj[p]);
for (i = 0; i < els.length; i++) {
if (els[i].name === p) {
els[i].defaultValue = obj[p];
break;
}
}
}
};
var bindPropertiesToValue = function(obj, els) {