【发布时间】:2019-09-18 03:45:18
【问题描述】:
我在使用swal确认删除时遇到了一些麻烦,我不知道如何使它工作
这是我的刀片视图文件:
<form action="{{ route('user.destroy', $us->id)}}" method="post">
@method('DELETE')
@csrf
<input class="btn btn-danger" type="submit" value="Delete" />
</form>
以及使用 swal 的脚本
<script>
//== Class definition
var SweetAlert2Demo = function() {
//== Demos
var initDemos = function() {
$('.btn-danger').click(function(e) {
e.preventDefault();
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
buttons:{
confirm: {
text : 'Yes, delete it!',
className : 'btn btn-success'
},
cancel: {
visible: true,
className: 'btn btn-danger'
}
}
}).then((Delete) => {
if (!Delete) {
e.preventDefault();
}
});
});
};
return {
//== Init
init: function() {
initDemos();
},
};
}();
//== Class Initialization
jQuery(document).ready(function() {
SweetAlert2Demo.init();
});
</script>
swal 的版本是https://sweetalert.js.org 而不是https://sweetalert2.github.io/
我在 laravel 5.8 上使用路由资源 谢谢你!
【问题讨论】:
-
swal 不工作??
-
我的问题是删除按钮与swal结合时我不知道如何处理。
标签: php laravel-5.8 sweetalert