Search code examples
onsen-ui

Onsen UI ons.notification.alert issue


the following code

var i=0;
i++;
ons.notification.alert({message: i});
i++;
ons.notification.alert({message: i});
i++;
ons.notification.alert({message: i});

The alert result is:

3
2
1

Could someone please explain the mechanism of Onsen Alert?

Thanks.


Solution

  • They are all displayed at the same time but the last one will be displayed on top of the others.

    If you want to display them sequentially you need to use the callback parameter.

    ons.notification.alert({
      message: 'First message',
      callback: function() {
        ons.notification.alert({
          message: 'Second message'
        });
      }
    });
    

    http://codepen.io/argelius/pen/qdoZXX