This is a migrated thread and some comments may be shown as answers.

Prevent user from double clicking Next button

6 Answers 520 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 12 Jun 2015, 04:33 PM

 

 Does anyone know of a way to easily prevent double clicking the next button. e.g. I dont want to charge the user's credit card twice.

 

Any help would be great. Thanks!

6 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 16 Jun 2015, 07:26 AM
Hello,

The Wizard's ButtonClicking event can be prevented conditionally as shown below:
function OnClientButtonClicking(sender, args) {
    var command = args.get_command();
    if (command == "1") {
        //condition
        if (true) {
            args.set_cancel(true);
        }
    }
}


Regards,
Ivan Danchev
Telerik
0
MBEN
Top achievements
Rank 2
Veteran
answered on 24 Oct 2017, 11:11 PM
Can you give me an example of the conditional logic to cancel the double click?
0
Ivan Danchev
Telerik team
answered on 25 Oct 2017, 02:45 PM
Hello,

Here's an example of how double clicking can be prevented without cancelling the ButtonClicking event:
<script type="text/javascript">
    function OnClientButtonClicking(sender, args) {
        var command = args.get_command();
        if (command == "1") {
            $telerik.$(".rwzNext").prop('disabled', true);
            setTimeout(function () {
                $telerik.$(".rwzNext").prop('disabled', false);
            }, 500)
        }
    }
</script>

With this approach we disable the Next button (finding it by its class "rwzNext") after it is clicked for certain amount of time (500 milliseconds in the snippet above) and then re-enable it so it can be used to navigate the Steps on single click.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
MBEN
Top achievements
Rank 2
Veteran
answered on 25 Oct 2017, 04:53 PM
This solution still skips the step for me, only it shows the intermediate step being skipped for a brief moment.
0
MBEN
Top achievements
Rank 2
Veteran
answered on 27 Oct 2017, 06:28 PM

Hi,

I am unable to figure out the condition that would check if the button was clicked twice.

Any help would be appreciated.

0
Ivan Danchev
Telerik team
answered on 30 Oct 2017, 02:03 PM
Hi,

The previously suggested approach prevents double clicking the Next button at my end. Here's a screencast showing:
1. First the default behavior, which causes navigation towards two steps to occur: e.g. if you start at Step1 and double-click Next the Wizard navigates to Step2 and then to Step3
2. The modified (by the logic in the OnClientButtonClicking event handler) behavior, which on double-click causes navigation to the next step only, instead of passing through 2 steps: e.g. starting from Step1 a double-click only navigates to Step2.

Attached you can find the sample runnable page used to record the screencast. Could you give it a try and let us know in case you notice a different behavior than the one demonstrated in the linked screencast?

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Wizard
Asked by
Jason
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
MBEN
Top achievements
Rank 2
Veteran
Share this question
or