Event not firing on button click
I'm trying to fire an event on an onclik inside a button, but the event does not fire. The button is inside a vue component and I am importing the function from another file.This is my code:
const csi = new CSInterface();
csi.addEventListener("com.my.extension.id.folderSelected", function(e){
alert('event fired')
});
//The imported function
function collect(){
let prompt = 'Select folder';
var path = esHandler(`KT.selectFolderDialog("${prompt}", true)`)
.then(function (res){
var event = new CSEvent("com.my.extension.id.folderSelected", "APLICATION");
event.data = res;
csi.dispatchEvent(event);
});
}
//Handler function for the asyncronicous behavior
function esHandler(script){
return new Promise(function(resolve, reject){
csi.evalScript(script, resolve);
});
}
The promise is resolved and the code within "then" is executed , but the alert within the "addevEntListener" is not executed.I have tried changing the scope of the CSEvent to "GLOBAL", but still not firing.The above code is all in the same file. What could be the problem? What am I doing wrong?
