admin管理员组文章数量:1387347
I want to create an alert similar to the ajax-example, but allowing outside click dismiss before confirming. After the user clicks confirm I would like to disallow outside click until the operation is finished.
Setting the config variable allowOutsideClick
to false like in the example will never allow outside click and I don't see a valid method in the docs to achieve this behavior programatically.
I want to create an alert similar to the ajax-example, but allowing outside click dismiss before confirming. After the user clicks confirm I would like to disallow outside click until the operation is finished.
Setting the config variable allowOutsideClick
to false like in the example will never allow outside click and I don't see a valid method in the docs to achieve this behavior programatically.
1 Answer
Reset to default 6It's possible to pass the function to the allowOutsideClick
parameter:
allowOutsideClick: () => {
// add your logic here and return boolean
}
Your case:
Swal.fire({
title: 'Submit email to run ajax request',
input: 'email',
showLoaderOnConfirm: true,
preConfirm: (email) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
}, 3000)
})
},
allowOutsideClick: () => !swal.isLoading()
})
<script src="https://cdn.jsdelivr/npm/sweetalert2@11"></script>
本文标签: javascriptSweetAlert2 disallow outside click after confirmStack Overflow
版权声明:本文标题:javascript - SweetAlert2 disallow outside click after confirm - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744544231a2611799.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论