Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Disable Save a second time Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Disable Save a second time

Unread post 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();
    }
}
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Disable Save a second time

Unread post 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');
    }
}
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Disable Save a second time

Unread post by admin »

toms,

I'm not sure I understand your question.

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

Steven
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Disable Save a second time

Unread post 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.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Disable Save a second time

Unread post 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
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Disable Save a second time

Unread post 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.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Disable Save a second time

Unread post by admin »

.
Post Reply