Best way to prevent onClick event firing twice?
Hi everyone
I am using AW controls for displaying a form (for editing a row in a grid) and I have experienced that on a slow performing server-client network, if the user presses the submission button twice quickly, the form can be submitted twice.
I understand that preventing this is standard javascript stuff, but I'm finding some difficulties. I have thought of trying to disable the button after it's been clicked (see a different post on disabling buttons) without much joy. I'm also trying to capture if the button has been pressed once and then preventing it firing the onClick a second time in the following way:
.. but again, I can't see that this is working (still seem able to submit twice). Is the above a valid approach to the problem, or can anyone suggest anything else?
Thanks
Will
I am using AW controls for displaying a form (for editing a row in a grid) and I have experienced that on a slow performing server-client network, if the user presses the submission button twice quickly, the form can be submitted twice.
I understand that preventing this is standard javascript stuff, but I'm finding some difficulties. I have thought of trying to disable the button after it's been clicked (see a different post on disabling buttons) without much joy. I'm also trying to capture if the button has been pressed once and then preventing it firing the onClick a second time in the following way:
submit_button = new AW.UI.Button;
submit_button.onClick= function(){
if (submitted) return false;
var submitted = true;
perform_validation_and_submission();
}
.. but again, I can't see that this is working (still seem able to submit twice). Is the above a valid approach to the problem, or can anyone suggest anything else?
Thanks
Will
Will
July 19,