使用 sweetalert 防止页面重新加载
Preventing the page reload with sweetalert
产品被移除后,我有一个甜蜜的提醒要显示。但是,页面在 sweetalert 的几毫秒内重新加载 window.location.reload();
。我怎么能不重新加载,除非我点击确定。就像正常的 alert()
。
swal({
title: "Product removed from your watchlist!",
type: "success",
confirmButtonClass: "btn-success",
confirmButtonText: "OK!",
closeOnConfirm: false
});
window.location.reload();
swal({
title: "Product removed from your watchlist!",
type: "success",
confirmButtonClass: "btn-success",
confirmButtonText: "OK!",
closeOnConfirm: false
}, function(isConfirm){
if (isConfirm) {
window.location.reload();
}
});
他们在演示中给出了一个这样的例子:http://t4t5.github.io/sweetalert/
检查那个说 - “......通过传递一个参数,你可以为取消执行其他事情”。
产品被移除后,我有一个甜蜜的提醒要显示。但是,页面在 sweetalert 的几毫秒内重新加载 window.location.reload();
。我怎么能不重新加载,除非我点击确定。就像正常的 alert()
。
swal({
title: "Product removed from your watchlist!",
type: "success",
confirmButtonClass: "btn-success",
confirmButtonText: "OK!",
closeOnConfirm: false
});
window.location.reload();
swal({
title: "Product removed from your watchlist!",
type: "success",
confirmButtonClass: "btn-success",
confirmButtonText: "OK!",
closeOnConfirm: false
}, function(isConfirm){
if (isConfirm) {
window.location.reload();
}
});
他们在演示中给出了一个这样的例子:http://t4t5.github.io/sweetalert/ 检查那个说 - “......通过传递一个参数,你可以为取消执行其他事情”。