小编Jam*_*es 的帖子

Sweet Alert 删除确认带有 href

我正在使用 PHP 和用于删除确认的甜蜜警报。问题是它在显示甜蜜警报之前正在删除。

这是我的 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>
Run Code Online (Sandbox Code Playgroud)

这是我的甜蜜警报

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!");
  }
});
Run Code Online (Sandbox Code Playgroud)

}

问题是,它没有显示甜蜜的警报,它只是直接转到 URL。我需要做一个表格并防止提交或类似的东西吗?

javascript php sweetalert

5
推荐指数
1
解决办法
7037
查看次数

标签 统计

javascript ×1

php ×1

sweetalert ×1