Javascript scope in two different script windows.
Hello,
I searched the helpf forums and I found that all javascript variables entered in captivate are supposed to be global.
But obviously I can't reference some variable in one script window which I defined in another script window.
I thought this should be possible.
I have a script for the "on enter slide" event which defines two functions:
try {
var alleSprecher =[];
function addSprecher(_element) {
if(alleSprecher.indexOf(_element) >= 0) {
alleSprecher[alleSprecher.length] = _element;
}
}
function notifyAlleSprecher() {
alleSprecher.forEach(sprecher => sprecher.classList.remove("anim");
}
}
catch(error) {
alert(error);
}
And I have a button with an advanced action that does call a script besides doing other things. In this script I call these two functions:
try {
var buttonElement = document.getElementById("SmartShape_Sprecherin_rotc");
addSprecher(buttonElement);
notifyAlleSprecher();
if(!(buttonElement.classList.contains("anim"))) {
buttonElement.classList.add("anim");
}
}
catch(error) {
alert(error);
}
When pressing the button this script throws a ReferenceError stating "addSprecher" is not defined.
What am I doing wrong?
Is this even possible in Captivate?
Any help is very appreciated.
