cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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

0 Likes
View Entire Topic
AbdelhalimDadouche
Active Contributor
0 Likes

Hi karthik.s31

I think you need to change your coding logic and use callbacks.

Instead of a simple loop, I would also use some resistivity with the MessageBox.confirm onClose callback where I would remove one array element after checking that element and then callback the intial entry point function.

The array would reduce as you check items.

Hope this helps

former_member190063
Participant
0 Likes

Hi Abdel,

Thanks. Would you please provide some example?

Regards

Karthik S