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();
}
});
}
});