How do you handle users who click a button multiple times before the script on the button has time to complete? I only want the script to run once regardless of how many times the button is clicked
Is there a way to do this within Verj?
Prevent clicking a button multiple times
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 53
- Joined: Wed Jan 02, 2013 4:23 pm
- Location: Lyndhurst, Hampshire
- Contact:
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Re: Prevent clicking a button multiple times
Yes you can do this pretty easily.
I just made a simple proof of concept that shows how this works and attached it to this post
In HTML entities for the button in my example, I put
for the click event which immediately hides the button as soon as you click on it on the client side. It won't work the way that you expect if you try to hide the button in the server side script so that's why you have to hide it on the client side.
In the script Buttonform_Button_Click, I put the command:
Packages.java.lang.Thread.sleep(5000);
to simulate a delay of 5 seconds while some kind of long running processing would normally be done then show the button after it completes.
So to answer your question, the best way to prevent the button event from firing multiple times is to hide or disable it.
Segi
I just made a simple proof of concept that shows how this works and attached it to this post
In HTML entities for the button in my example, I put
Code: Select all
document.getElementById('testBtn').style.display = 'none'
In the script Buttonform_Button_Click, I put the command:
Packages.java.lang.Thread.sleep(5000);
to simulate a delay of 5 seconds while some kind of long running processing would normally be done then show the button after it completes.
So to answer your question, the best way to prevent the button event from firing multiple times is to hide or disable it.
Segi
- Attachments
-
- ButtonExample.zip
- proof of concept
- (3.32 KiB) Downloaded 277 times
0 x
-
- Ebase User
- Posts: 53
- Joined: Wed Jan 02, 2013 4:23 pm
- Location: Lyndhurst, Hampshire
- Contact:
Who is online
Users browsing this forum: No registered users and 5 guests