Skip to content

Instantly share code, notes, and snippets.

@davecra
Created July 27, 2017 21:18
Show Gist options
  • Save davecra/fca28639a7c96e1cc1cd8f2bb15f2f18 to your computer and use it in GitHub Desktop.
Save davecra/fca28639a7c96e1cc1cd8f2bb15f2f18 to your computer and use it in GitHub Desktop.
Using the closeDialogAsync() function you can now open one dialog right after another
var i = 0;
function displayDialog() {
var url = "https://localhost:3000/test.html";
Office.context.ui.displayDialogAsync(url,{height:20, width:30, displayInIframe:true},
function (asyncResult) {
var dialog = asyncResult.value; // get the dialog
var error = asyncResult.error;
if(dialog == undefined && error.code > 0) {
// log the error
console.log(error.message);
} else {
// attache the events
dialog.addEventHandler(Office.EventType.DialogEventReceived, function (arg) {
// close this dialog, open the next
dialogCloseAsync(dialog, function() {
i++;
if(i<4) {
displayDialog();
}
});
});
dialog.addEventHandler(Office.EventType.DialogMessageReceived, function (arg) {
// close this dialog, open the next
dialogCloseAsync(dialog, function() {
i++;
if(i<4) {
displayDialog();
}
});
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment