Welcome to the nuBuilder Forums!

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

function nuOnLoad() runs twice, onLoad and when saving

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

function nuOnLoad() runs twice, onLoad and when saving

Unread post by yvesf »

Hello,

I have put a function nuOnLoad() behind a form. I am surprised that this function is running when loading the form but also when saving. If anyone could explain me how this function works, it would be nice.
Code behind the function nuOnLoad()

Code: Select all

function nuOnLoad(){
  

   if ((nuFormType() == 'edit') {
                let oldlbl=nuGetValue('tsk_label');
                 console.log('oldlbl in nuOnLoad : ' + oldlbl);
               

   }
}
and the trace in the console log prove that it traces when loading but also on saving. I would be interested to capture the value before saving. How can I do that ?
Thanks Yves
kev1n
nuBuilder Team
Posts: 4303
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: function nuOnLoad() runs twice, onLoad and when saving

Unread post by kev1n »

nuOnLoad() should only be used under Setup -> Header, but not in a form.
Post Reply