jen
06/24/2022, 10:23 PMrequire
and as such, the script is loaded afresh and the value of the global variable is reset.jen
06/24/2022, 10:23 PMjen
06/24/2022, 10:23 PM/
* cf_mycustomform_ss2.1.js
* @NApiVersion 2.1
* @NScriptType ClientScript
*/
define([], function() {
var thing = 'fish';
function pageInit() {
// Should show 'fish';
logValueOfThing();
}
function fieldChanged() {
setThingToApple();
// Should show 'apple';
logValueOfThing();
}
function setThingToApple() {
thing = 'apple';
}
function logValueOfThing() {
console.log('Value of thing is now ' + thing);
}
return {
fieldChanged: fieldChanged,
pageInit: pageInit,
setThingToApple: setThingToApple,
logValueOfThing: logValueOfThing
}
});
jen
06/24/2022, 10:24 PMmichoel
06/24/2022, 11:54 PMwindow.thing
michoel
06/24/2022, 11:55 PMbattk
06/25/2022, 12:01 AMbattk
06/25/2022, 12:05 AMthing
is being accessed as part of the closureMarvin
06/25/2022, 12:12 AMsetThingToApple
& logValueOfThing
unless these methods need to be externally available.