0
我想在表单提交时执行一些操作。但首先我想检查表单是否应该删除任何东西。事情是,我不能让我的表单再次提交。我该如何解决?防止表单提交到SweetAlert为真
$('body').on('submit', 'form', function (e)
{
let self = $(this);
if (self.find('input[name="_method"]').val() == 'DELETE')
{
e.preventDefault();
swal({
title: window.translations.delete_item_title,
text: window.translations.delete_item_content,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: window.translations.delete_item_confirm,
cancelButtonText: window.translations.delete_item_cancel,
closeOnConfirm: false
},
function (input)
{
if(input){
$(this).submit();
}
});
}
});