NetTalk Central

Author Topic: Disable Save after click?  (Read 5086 times)

willieb

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • Email
Disable Save after click?
« 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?

debzidoodle

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
    • Email
Re: Disable Save after click?
« Reply #1 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
« Last Edit: January 31, 2014, 11:23:58 AM by debzidoodle »

willieb

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • Email
Re: Disable Save after click?
« Reply #2 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.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Disable Save after click?
« Reply #3 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')

willieb

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • Email
Re: Disable Save after click?
« Reply #4 on: February 02, 2014, 11:23:46 PM »
Thanks Bruce

debzidoodle

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
    • Email
Re: Disable Save after click?
« Reply #5 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/

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Disable Save after click?
« Reply #6 on: February 03, 2014, 06:54:29 PM »
ahh - thanks Debra - hadn't come across that one before....