Disable Save a second time

Questions related to using nuBuilder Forte.

Disable Save a second time

Postby toms » Wed Feb 14, 2018 12:50 am

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();
    }
}
toms
 

Re: Disable Save a second time

Postby toms » Wed Feb 14, 2018 12:54 am

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');
    }
}
toms
 

Re: Disable Save a second time

Postby admin » Wed Feb 14, 2018 1:18 am

toms,

I'm not sure I understand your question.

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

Steven
admin
Site Admin
 
Posts: 3309
Joined: Mon Jun 15, 2009 9:53 am

Re: Disable Save a second time

Postby toms » Wed Feb 14, 2018 1:28 am

The action buttons will become visible again after the save process has been completed. Hence, the form can be submitted/saved a second time.
toms
 

Re: Disable Save a second time

Postby admin » Wed Feb 14, 2018 5:21 am

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
admin
Site Admin
 
Posts: 3309
Joined: Mon Jun 15, 2009 9:53 am

Re: Disable Save a second time

Postby toms » Wed Feb 14, 2018 4:49 pm

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.
toms
 

Re: Disable Save a second time

Postby admin » Wed Feb 14, 2018 8:10 pm

.
admin
Site Admin
 
Posts: 3309
Joined: Mon Jun 15, 2009 9:53 am


Return to General



cron