Well,
I looked into struts2 jquery plugin code here o.validate calls validate function in struts2 while o.options.submit when set to false does not calls the actual action.
Now if my client side validation is should be able to block ajax validation too.
But here, I am not able to set event.originalEvent.validate = false hence ajax validation will happen always.
Need someway to fix this is native library to have a use case, where client side validation must be able to revoke server side validation and avoid network call.
params.beforeSubmit = function(formData, form, formoptions) {
var orginal = {};
orginal.formData = formData;
orginal.form = form;
orginal.options = formoptions;
orginal.options.submit = true;
s2j.publishTopic(elem, always, orginal);
if (o.onbef) {
$.each(o.onbef.split(','), function(i, topic) {
elem.publish(topic, elem, orginal);
});
}
if (o.validate) {
orginal.options.submit = s2j.validateForm(form, o);
orginal.formvalidate = orginal.options.submit;
if (o.onaftervalidation) {
$.each(o.onaftervalidation.split(','), function(i, topic) {
elem.publish(topic, elem, orginal);
});
}
}
if (orginal.options.submit) {
s2j.showIndicator(indi);
if(!o.datatype || o.datatype !== "json") {
if (o.loadingtext && o.loadingtext !== "false") {
$.each(o.targets.split(','), function(i, target) {
$(s2j.escId(target)).html(o.loadingtext);
});
}
else if (s2j.defaults.loadingText !== null) {
$.each(o.targets.split(','), function(i, target) {
$(s2j.escId(target)).html(s2j.defaults.loadingText);
});
}
}
}
return orginal.options.submit;
};
params.success = s2j.pubSuc(elem, always, o.onsuc, indi, 'form', o);
params.complete = s2j.pubCom(elem, always, o.oncom, o.targets, indi, o);
params.error = s2j.pubErr(elem, always, o.onerr, o.errortext, 'html');
$.each(o.formids.split(','), function(i, fid) {
s2j.log('submit form : ' + fid);
$(s2j.escId(fid)).ajaxSubmit(params);
});
return false;
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…