Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Questions related to using nuBuilder Forte.
toms
Posts: 785 Joined: Sun Oct 14, 2018 11:25 am
Unread post
by toms » Tue Feb 13, 2018 4:20 pm
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
Unread post
by toms » Tue Feb 13, 2018 4:24 pm
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
Unread post
by admin » Tue Feb 13, 2018 4:48 pm
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
Unread post
by toms » Tue Feb 13, 2018 4:58 pm
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
Unread post
by admin » Tue Feb 13, 2018 8:51 pm
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
Unread post
by toms » Wed Feb 14, 2018 8:19 am
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.