【发布时间】:2019-05-15 10:47:29
【问题描述】:
我在 Sweetalert 上遇到了这个问题 - 我有以下代码,但确认模式没有用,因为请求通过了它,用户甚至没有时间决定。我必须弄清楚停止请求执行并等待用户决定(确定/取消)。
代码如下:
<a href="{{route('notes.destroy', $note->id)}}"
data-id="{{$note->id}}" onclick="confirmDelete('{{$note->id}}')" type="submit">
<span class="badge badge-danger">Delete</span></a>
这是 jQuery(我认为这是问题所在):
<script>
function confirmDelete(item_id) {
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover it!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
$('#' + item_id).submit();
} else {
swal("Cancelled Successfully");
}
});
}
</script>
【问题讨论】:
标签: jquery laravel sweetalert