I’m in an interesting situation maintaining legacy code here. I need to modify a button that opens a child window so that the function run by clicking the button pauses execution until the child window closes. The javascript for this event is all embedded in the html of the button and there appears to be variables that can be accessed from within the html scope but not from any external script I can make.
genBtn.outerHTML = `<a class="button110x25blue" href="#" id="${mktSelName}" name="${mktSelName}" onclick="
async () => {
let childPromise;
A4J.AJAX.Submit('reportSelect',event,{
'oncomplete':function(request,event,data){javascript: () => {childPromise = openWindow();}},
'similarityGroupingId':'${mktSelName}',
'parameters':{'${mktSelName}':'${mktSelName}'} ,
'containerId':'${mktSelName}_2'});
await childPromise;
return false;}">Generate Report</a>`
The code is generated in the html fine and looks correct to me. I’m just unsure of proper use of promises in a case such as this.
The current behavior is that a child window is opened, but the execution doesn’t pause, so a bunch of child windows end up being opened too fast and the server I’m working with just starts giving me errors (It limits how many requests for data for child windows I can make at any given time).