Stop the control while SweetAlert is on screen [duplicate]

荒凉一梦 提交于 2019-12-01 21:34:58
nem035

Creating the swal is an asynchronous process, meaning you cannot just return a synchronous result from it.

If you look at the docs, you can see that swal returns a promise, so you can take advantage of that and pass the success and fail callbacks:

ConfirmationMessage = function(msg) {
  return swal({ ... }); // <--- return the swal call which returns a promise
};

ConfirmationMessage('message to show')
  .then(function() {
    // success happened
  }, function(dismiss) {
    // fail happened
    // dismiss can be 'cancel', 'overlay', 'close', and 'timer'
    if (dismiss === 'cancel') {
      // user cancelled
    }
  });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!