PDA

View Full Version : prevent double save / click event on button



mdissel
20 Jul 2010, 6:47 AM
Hello

i've got a Ext.Window instance with save / cancel buttons. I want to prevent that an user can click on Save multiple times.. I've tried single:true on the click event, but it's still possible to click multiple times on the button... (very quickly)

Tips?

Thanks

evant
20 Jul 2010, 6:49 AM
Disable the button after they click on it.

mdissel
20 Jul 2010, 7:12 AM
Of course .. (although the combination of client/server side validation makes it complex to enable the button again if validation is invalid)

arthurakay
20 Jul 2010, 8:14 AM
You can easily re-enable the button from a callback method.

Ext.form.Action.Submit() and Ext.Ajax.request() both have success/failure callbacks that you can use to re-enable the button. It's pretty simple.

mdissel
20 Jul 2010, 10:53 PM
Yes i know, but this is inside a base class, so it's need some refactoring to allow this.

Animal
20 Jul 2010, 11:08 PM
Re-enable on a delay then.

mdissel
21 Jul 2010, 1:14 AM
And with what delay time? 10 seconds? 30 seconds? it depends on the reaction of the server (and the timeout of Ajax request of course), but issue solved!

arthurakay
21 Jul 2010, 5:09 AM
Yes i know, but this is inside a base class, so it's need some refactoring to allow this.

Why not just extend the class?