我希望用户在单击删除按钮后确认删除(使用类 .delete)我使用 Noty js 并包含其脚本 src:
<script src="{{asset('dashboard_files/plugins/noty/noty.min.js')}}"></script>
带有 .delete 类的删除按钮:
<button type="submit" class="btn btn-danger .delete"><i class="fa fa-trash"></i>Delete</button>
我在 app.blade 中的 Jquery 函数让用户确认删除或取消:
<script>
$(document).ready(function(){
$(document).on('click','.delete', function(e){
e.preventDefault();
var that = $this
var n = new Noty({
text:'Confirm deleting record',
killer:true,
buttons:[
Noty.button('yes', 'btn btn-danger mr-2', function(){
that.closest('form').submit()
}),
Noty.button('no','btn btn-danger',function(){
n.close()
}),
]
}) //end of var n
n.show();
}); //end of onclick
}); //end of ready fn
</script>
深深的感谢;