【发布时间】:2020-03-11 17:39:59
【问题描述】:
嘿伙计们,当用户确认删除时,我对 swal 条件有一点问题,什么也没发生 (swal 版本 7.0.7)
有swal代码
<form id="del_type" action="{{ route('admin.type.destroy', $type->id) }}" method="post"style="display: inline">
{!! method_field('delete') !!}
{{ csrf_field() }}
<button class="btn btn-danger delete_type" type="submit" >Supprimer</button>
</form>
$(".delete_type").click( function (e) {
e.preventDefault();
var _this = $(this)
//console.info(_this.parent().prop('action'))
swal({
title: "Attention",
text: "Veuillez confirmer la suppression",
type: "warning",
showCancelButton: true,
confirmButtonText: "Confirmer",
cancelButtonText: "Annuler",
}, function(result) {
if(result) {
$('#del_type').submit();
} else {
swal('cancelled');
}
});
});
当我单击删除按钮时,它会显示带有确认和取消按钮的 swal,但是当您单击确认时没有任何反应并且没有提交 (对不起我的英语)
【问题讨论】:
-
尝试使用 result.value 而不是 result
if(result.value) { $('#del_type').submit(); } -
你能在你的回调函数中这样检查吗(结果){ $('#del_type').submit(); }
-
我解决了我使用的问题 .then 并且知道它正在工作 .then((result) => { if (result.value) { _this.parent().submit(); } else { }
标签: javascript jquery laravel laravel-5 laravel-blade