【发布时间】:2020-02-28 13:42:23
【问题描述】:
我在 sweetalert2 中使用复选框:
$(document).on("click", "#deleteUploadedFile", function () {
Swal.fire({
title: 'Are you sure you want to remove selected uploads?',
type: 'warning',
input: 'checkbox',
inputValue: 1,
inputPlaceholder:
'Delete Permanently',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, Remove them!',
}).then((result) => {
console.log(result);
if (result.value) {
$('#deleteUploadsForm').submit();
}
})
});
使用此代码,表单无法提交,因为如果未选中,result.value 将变为 0。
但是,如果我删除以下 3 个选项,它就可以正常工作。
input: 'checkbox',
inputValue: 1,
inputPlaceholder:
'Delete Permanently',
但是,我想发送此复选框值,以便我可以软删除或强制删除服务器上的数据。
【问题讨论】:
标签: jquery sweetalert2