Page 1 of 1

Disable Save a second time

Posted: Tue Feb 13, 2018 4:20 pm
by toms
Hi,

How do I make the entire form (or all objects on it) read-only once a user has clicked on Save?
Sometimes when the response is slow, one might click the save button multiple times. How to prevent this from happening?

One possibility would be to hide the save button but nuUpdateData() will set it to visible again.

Code: Select all

function nuBeforeSave() {
    if (nuFORM.edited == true) {
        $('nuSaveButton').hide();
    }
}

Re: Disable Save a second time

Posted: Tue Feb 13, 2018 4:24 pm
by toms
It works like this - Maybe there is a more elegant way of doing it?

Code: Select all

if (nuFormType() == 'edit') {
    if (nuGetProperty("alreadySaved") == "1") {
         $('#nuSaveButton')
          .prop('disabled', true)
           .css({'background-color':'grey', 'border-color':'grey'})
    }
}

function nuBeforeSave() {
    if (nuFORM.edited == true) {
     	nuSetProperty('alreadySaved','1');
    }
}

Re: Disable Save a second time

Posted: Tue Feb 13, 2018 4:48 pm
by admin
toms,

I'm not sure I understand your question.

nuSaveAction() hides all Action Buttons when it is called.

Steven

Re: Disable Save a second time

Posted: Tue Feb 13, 2018 4:58 pm
by toms
The action buttons will become visible again after the save process has been completed. Hence, the form can be submitted/saved a second time.

Re: Disable Save a second time

Posted: Tue Feb 13, 2018 8:51 pm
by admin
toms,

If you want to save only new records - I'm not sure if that's what you mean.

Then you can do this in the Form's Javascript...

Code: Select all


if(!nuIsNewRecord()){
   $('#nuSaveButton').remove();
}

Steven

Re: Disable Save a second time

Posted: Wed Feb 14, 2018 8:19 am
by toms
Steven,

Your solution would work too.
Actually, I just want to prevent an email from being sent a second time (PHP, AS), so I thought that disabling the save button would prevent it, but maybe I should try another approach. E.g. by doing the check in the AS part.

Re: Disable Save a second time

Posted: Wed Feb 14, 2018 11:40 am
by admin
.