Submit button disable on click not calling correct method - calls execute() only

981 Views Asked by At

I've searched and found answers how to disable all submit buttons when clicked to prevent double form submission.

$('#annCreateEdit').click(function(){
    $('input[type=submit]', this).attr('disabled', true);
});

Unfortunately, the effect it has means the correct struts 2 method is no longer being called, it is defaulting to calling the execute() method.

My JavaScript skills are very poor and by extension so too are my jQuery skills.

Assistance with disabling the (or all) submit buttons while still calling the correct method would be very much appreciated. Thank you!

1

There are 1 best solutions below

3
On

Try this

 $('#annCreateEdit').click(function(){
    $('input[type=submit]').attr("disabled", "disabled");
    return false;
 });

If you are using Jquery 1.6 or above then you can use also as below:

 $('#annCreateEdit').click(function(){
    $('input[type=submit]').prop('disabled', true);
    return false;
 });