You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alex Grant <al...@unimarket.com> on 2010/10/28 23:39:08 UTC

Disable button double-click without breaking Form.setDefaultButton

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

RE: Disable button double-click without breaking Form.setDefaultButton

Posted by Alex Grant <al...@unimarket.com>.
Thank you for your help, problem solved.

-----Original Message-----
From: Jeremy Thomerson [mailto:jeremy@wickettraining.com] 
Sent: Friday, 29 October 2010 5:59 p.m.
To: users@wicket.apache.org
Subject: Re: Disable button double-click without breaking Form.setDefaultButton

Do it in your form itself.  For instance, you can save a boolean flag that tells you that the form has already been submitted and not accept a second submit, or whatever.

On Thu, Oct 28, 2010 at 9:58 PM, Alex Grant <al...@unimarket.com>wrote:

> Thanks,
>
> That was actually me asking that question. :) That worked perfectly 
> for AjaxButtons, but what I'm trying to do now is disable double-click 
> for non-ajax buttons.
>
> Alex
>
> -----Original Message-----
> From: Alexander Morozov [mailto:alexander.v.morozov@gmail.com]
> Sent: Friday, 29 October 2010 3:31 p.m.
> To: users@wicket.apache.org
> Subject: Re: Disable button double-click without breaking 
> Form.setDefaultButton
>
>
> Check this thread
>
> http://apache-wicket.1842946.n4.nabble.com/Preventing-double-click-of-
> AjaxButtons-in-ModalWindow-td2289480.html
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Disable-button-double-click
> -without-breaking-Form-setDefaultButton-tp3018140p3018370.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


--
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Disable button double-click without breaking Form.setDefaultButton

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Do it in your form itself.  For instance, you can save a boolean flag that
tells you that the form has already been submitted and not accept a second
submit, or whatever.

On Thu, Oct 28, 2010 at 9:58 PM, Alex Grant <al...@unimarket.com>wrote:

> Thanks,
>
> That was actually me asking that question. :)
> That worked perfectly for AjaxButtons, but what I'm trying to do now is
> disable double-click for non-ajax buttons.
>
> Alex
>
> -----Original Message-----
> From: Alexander Morozov [mailto:alexander.v.morozov@gmail.com]
> Sent: Friday, 29 October 2010 3:31 p.m.
> To: users@wicket.apache.org
> Subject: Re: Disable button double-click without breaking
> Form.setDefaultButton
>
>
> Check this thread
>
> http://apache-wicket.1842946.n4.nabble.com/Preventing-double-click-of-AjaxButtons-in-ModalWindow-td2289480.html
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Disable-button-double-click-without-breaking-Form-setDefaultButton-tp3018140p3018370.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

RE: Disable button double-click without breaking Form.setDefaultButton

Posted by Alex Grant <al...@unimarket.com>.
Thanks,

That was actually me asking that question. :)
That worked perfectly for AjaxButtons, but what I'm trying to do now is disable double-click for non-ajax buttons.

Alex

-----Original Message-----
From: Alexander Morozov [mailto:alexander.v.morozov@gmail.com] 
Sent: Friday, 29 October 2010 3:31 p.m.
To: users@wicket.apache.org
Subject: Re: Disable button double-click without breaking Form.setDefaultButton


Check this thread
http://apache-wicket.1842946.n4.nabble.com/Preventing-double-click-of-AjaxButtons-in-ModalWindow-td2289480.html
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Disable-button-double-click-without-breaking-Form-setDefaultButton-tp3018140p3018370.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Disable button double-click without breaking Form.setDefaultButton

Posted by Alexander Morozov <al...@gmail.com>.
Check this thread
http://apache-wicket.1842946.n4.nabble.com/Preventing-double-click-of-AjaxButtons-in-ModalWindow-td2289480.html
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Disable-button-double-click-without-breaking-Form-setDefaultButton-tp3018140p3018370.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org