Reputation: 11824
I wish to achieve that program will not proceed to next line in code until user click close
button on messageDialog
. Is that possible?
In this example I wish to change document background color to red until user click close
. After this it will go back to white background. So I wish to have red color of backround only when messageDialog is active/visible/shown.
Globals["messageDialog"]("Something went wrong!", "#FF0000");
WinJS.Namespace.define("Globals", {
messageDialog: function (string) {
Windows.UI.Popups.MessageDialog(string).showAsync();
document.body.style.backgroundColor = "#FF0000";
}
});
Upvotes: 0
Views: 433
Reputation: 526
use Await keyword
await Windows.UI.Popups.MessageDialog(string).showAsync();
Upvotes: 0
Reputation: 7211
Sure, the showAsync()
returns a promise which completes only when the user closed the dialog. So just write something like
Windows.UI.Popups.MessageDialog(string).showAsync().done(function () {
document.body.style.backgroundColor = "#FF0000";
});
Upvotes: 1