Hello,

I have had problems with users double-clicking the Finish button in one of our 
wizards, which caused duplicate objects to be created.

So I want to prevent the (non-ajax) buttons from being clicked more than once. 
I found what I thought was a good solution, using a SimpleAttributeModifier to 
add this to all the regular buttons
<input ... onclick="this.onclick=function(){return false;};"/>

This worked fine, until someone discovered pressing Enter in a textfield in a 
wizard stopped working, not only did it not submit the form, but it prevented 
clicking the button manually. Wizard makes uses of Form.setDefaultButton, which 
adds a hidden button at the start of the form, with an onclick handler that 
looks like this:

<input ... onclick="var b=document.getElementById('next2d'); if 
(b!=null&&b.onclick!=null&&typeof(b.onclick) != 'undefined') {  var r = 
b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };  return 
false;" />

This meant that the onclick() method of my button was invoked (disabling the 
button), and then the button was clicked (doing nothing).

Has anyone found a way of disabling double-click on regular buttons without 
tripping over this?

Thank you,
Alex

Reply via email to