NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: willieb on January 30, 2014, 02:00:47 AM

Title: Disable Save after click?
Post by: willieb on January 30, 2014, 02:00:47 AM
Hi, is there a way to disable the save button after clicking on it?

I have a Memory form with the normal save & cancel buttons.  When save is clicked I do some validations(ValidateAllStart).  Then at (ValidateAllEnd) embed I add a record to a table, after adding I give the user a popup to show the record have been added.

What happens now is the user click once, then after a second nothing happened, then clicks again, and again ... then the record get added more than once.  The problem is their network/internet is very slow.

Is there a way to disable or even hide the save button after the first click?

Or any other suggestions to fix my problem?
Title: Re: Disable Save after click?
Post by: debzidoodle on January 31, 2014, 10:59:51 AM
I have the same issue. Try adding this code to your xhtml tab of the form, and set the location to "Before <form>"

Code: [Select]
<script>$("button[name=save_btn]").one("click", function() {
   $(this).attr("disabled","disabled");
});
</script>

Hope that helps,
Debra
Title: Re: Disable Save after click?
Post by: willieb on January 31, 2014, 09:45:35 PM
Thank will try and let you know.

In the mean time I added a normal button which call another form just to display "busy processing" while waiting for the server, and returning when done.  The saving/processing is done on the "busy processing" form.
Title: Re: Disable Save after click?
Post by: Bruce on February 02, 2014, 10:47:02 PM
I'll add this to an upcoming build.

...and I think there's a typo in Dbra's example, should be on('click') not one('click')
Title: Re: Disable Save after click?
Post by: willieb on February 02, 2014, 11:23:46 PM
Thanks Bruce
Title: Re: Disable Save after click?
Post by: debzidoodle on February 03, 2014, 05:13:19 AM
No not a typo, makes it so the event only fires once, even if it is clicked again.

http://api.jquery.com/one/
Title: Re: Disable Save after click?
Post by: Bruce on February 03, 2014, 06:54:29 PM
ahh - thanks Debra - hadn't come across that one before....