admin管理员组文章数量:1289507
i am using sweetalert to display delete confirmation,and process it later while displayin a loading action,though it is not working,thi is the code,that doesn't work (it is supposed to display a loading animation,but it actually is not doing so) any thoughts ?
This the javascript
document.querySelector('div.test').onclick = function() {
swal({
title: 'Ajax request example',
text: 'Submit to run ajax request',
type: 'info',
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
}, function(){
setTimeout(function() {
swal('Ajax request finished!');
}, 2000);
});
};
Html
<div class="test">
<button>show alert</button>
</div>
this is the fiddle
i am using sweetalert to display delete confirmation,and process it later while displayin a loading action,though it is not working,thi is the code,that doesn't work (it is supposed to display a loading animation,but it actually is not doing so) any thoughts ?
This the javascript
document.querySelector('div.test').onclick = function() {
swal({
title: 'Ajax request example',
text: 'Submit to run ajax request',
type: 'info',
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
}, function(){
setTimeout(function() {
swal('Ajax request finished!');
}, 2000);
});
};
Html
<div class="test">
<button>show alert</button>
</div>
this is the fiddle
Share Improve this question asked Aug 21, 2016 at 18:14 MrRobotMrRobot 5011 gold badge7 silver badges18 bronze badges2 Answers
Reset to default 5Sweetalert is unsupported anymore. You might want to switch to sweetalert2:
Swal.fire({
title: 'Ajax request example',
text: 'Submit to run ajax request',
icon: 'info',
showCancelButton: true,
showLoaderOnConfirm: true,
preConfirm: function() {
return new Promise(function(resolve, reject) {
// here should be AJAX request
setTimeout(function() {
resolve();
}, 1000);
});
},
}).then(function() {
Swal.fire('Ajax request finished!');
});
<script src="https://cdn.jsdelivr/npm/sweetalert2@11"></script>
I assume your include files are wrong (old for instance).
The snippet:
$(function () {
$('div.test').on('click', function (e) {
swal({
title: "Ajax request example",
text: "Submit to run ajax request",
type: "info",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
}, function () {
setTimeout(function () {
swal("Ajax request finished!");
}, 2000);
});
})
});
<script src="https://code.jquery./jquery-1.12.4.min.js"></script>
<link href="https://rawgit./t4t5/sweetalert/master/dist/sweetalert.css" rel="stylesheet">
<script src="https://rawgit./t4t5/sweetalert/master/dist/sweetalert.min.js"></script>
<div class="test">
<button>show alert</button>
</div>
本文标签: javascriptSweetAlert showLoaderOnConfirm not displayingStack Overflow
版权声明:本文标题:javascript - SweetAlert showLoaderOnConfirm not displaying - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741426297a2378097.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论