简体   繁体   中英

Windows 8 Javascript apps multiple Message alerts

In my application, I need to display multiple message popups. However it doesn't work. It can be illustrated by the simple code below:

function alert(title, content) {
  try {
     var msg = new Windows.UI.Popups.MessageDialog(content, title);

    msg.showAsync();
  }
  catch (err) {
  }
}

I have a server side method which invokes this alert, at times I may have multiple alerts. There I get the following error: WinRTError: Access is denied.

Hence only 1 alert is shown and the second one goes in the catch. How to achieve multiple alerts from a windows 8 app?

I think you have to use Toast Notification Here is the code sample .

other wise you should chaining the message from server side. means first store particular messages in array then display one by one. and delete which message is displayed.

You can use promises to display popups.. like

var msg = new Windows.UI.Popups.MessageDialog(content, title);
var msg1 = new Windows.UI.Popups.MessageDialog(content, title);
var msg2 = new Windows.UI.Popups.MessageDialog(content, title);

msg.showAsync().then(function(){

return msg1.showAsync();

   }).then(function(){

return msg2.showAsync();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM