我正在尝试使用 sweetAlert2 确认对话框覆盖默认的确认()对话框。
但是,它会继续返回并继续删除过程,而无需单击“确定”。
$("a.confirm").click(function(){
swal({
title: 'Are you sure?',
text: $(this).attr('data-message'),
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes',
closeOnConfirm: true },
function(isConfirm) {
if(isConfirm === true){
alert('it is true');
} else {
return false;
}
});
});
这个想法很简单。我在任何可能需要确认的链接上都有一个类,确认消息被分配给数据消息属性。
通常情况下,它会自动跳到 URL,而不是等待单击 OK 按钮。
我查看了显示附加对话框的示例,该对话框向用户表示感谢,但在这种情况下,我试图仅在单击“确定”时才返回 true。不显示附加对话框。
非常感谢任何提示