【发布时间】:2019-02-09 05:57:53
【问题描述】:
我正在使用 PHP,并使用 Sweet 警报进行删除确认。问题是它在显示甜蜜警报之前正在删除。
这是我的 HTML(其中使用了 PHP)。
<div class="delete"><a onclick="return confirmation()" href="'.URLROOT.'/dashboards/delete_note/'.htmlspecialchars($note->note_id).'/'.$data['table'] .'"><i class="far fa-trash-alt"></i></a></div>
这是我的甜蜜提醒
function confirmation() {
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal("Poof! Your imaginary file has been deleted!", {
icon: "success",
});
} else {
swal("Your imaginary file is safe!");
}
});
}
问题是,它没有显示甜蜜警报,它只是直接进入 URL。我需要做一个表格并防止提交或类似的东西吗?
【问题讨论】:
-
ev.target.offsetParent.children[0].href
标签: javascript php sweetalert