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
Request clarification before answering.
Hi,
I think this might help.
Check this link I found thru google: StackOverflow - JS Closure inside loops.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.