Open GoogleCodeExporter opened 9 years ago
To be simple, I want to have a customize callback when the ajax form was
submitted successfully while do not have extra HTTP request.
That is the two operation of validation and submit merge into one.
Original comment by kagi...@gmail.com
on 19 Jan 2013 at 2:43
You don't need to use the built-in clientValidation Feature. You can use your
own way to validate your form.
Original comment by johgep
on 21 Jan 2013 at 12:50
Well, that a solution. But why don't integrate into the project? Here is my
solution currently:
$(function(){
var sj=jQuery.struts2_jquery,$form=$("#register_form"),params={
type:"POST",
data:{
"struts.enableJSONValidation": true
},
url:$form[0].action,
async:false,
cache:false,
complete:function(request, status) {
// console.log("@complete");
// console.log(request);
// console.log(status);
},
success:function(data){ //*** my call back
if(data.code===0){
alert(data.message);// TODO
}else{
bootstrapValidation($form,data);
}
},
dataType:"json"
};
sj.require("js/plugins/jquery.form" + sj.minSuffix + ".js");
$form.submit(function(){
$form.ajaxSubmit(params);
return false;
});
});
And, I want to make it simple by just writing my call back. And the code I
think would like:
<j:submit cssClass="btn btn-primary" formIds="register_form" validate="true"
verifySuccess="customCallback" validateFunction="bootstrapValidation"/>
<script>
function customCallback(data){ //*** my call back
if(data.code===0){
alert(data.message);// TODO
}else{
bootstrapValidation($form,data);
}
}
</script>
Notice: when customCallback is not empty, the struts.validateOnly need to be
false.
I hope you think about it.
Original comment by kagi...@gmail.com
on 21 Jan 2013 at 12:58
Original issue reported on code.google.com by
kagi...@gmail.com
on 19 Jan 2013 at 2:37