cancel
Showing results for 
Search instead for 
Did you mean: 

MessageBox callback event in loop

former_member190063
Participant
0 Kudos
477

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

View Entire Topic
agrawalaadhar8
Participant
0 Kudos

Hi,

I think this might help.

Check this link I found thru google: StackOverflow - JS Closure inside loops.

Regards.