Skip to Content
0
Jul 16, 2019 at 01:47 PM

MessageBox callback event in loop

231 Views

Hi,

I have a MessageBox in my for loop. There are two buttons (yes and No) inside messageBox. I am expecting the loop control to wait until user action from the MessageBox buttons. Would it be possible. I know MessageBox is asynchronous. I am looking for an alternative.

Example:

var array = [file1, file2, file3];

for(var i = 0; i < array.length; i++){

if(array[i] === "file1"){

MessageBox.confirm("File exists already. Do you want to Replace or Create?", { actions: ["Yes", "No"],

onClose: function (sAction) {

if (sAction === "Yes") {

//Make a call to backend

//

} else {

//Make a call to backend

} }});

}

I have to validate for each element in the array. Whenever matches found, Messagebox appears and user has to select the buttons inside it. But loop control won't stops for user event from MessageBox. Can we use nested callbacks in this case?

Thanks in advance.

Regards

Karthik S