在 SweetAlert2 上选择 'Cancel' 时如何防止关闭模式?
How can I prevent closing of the modal when 'Cancel' is selected on SweetAlert2?
我不希望在单击 'cancel(delete)' 按钮时关闭模式,只有在失去焦点或单击关闭按钮时才关闭。如何防止关闭?
默认取消按钮用于关闭对话框。您可以将自定义按钮添加为 html,并手动处理它们的点击事件,而不是为其他任务修改该按钮:(Run it live)
var onBtnClicked = (btnId) => {
// Swal.close();
alert("you choosed: " + btnId);
};
Swal.fire({
title: "What you want to do?",
icon: "warning",
showConfirmButton: false,
showCloseButton: true,
html: `
<p>select an action</p>
<div>
<button class="btn btn-primary" onclick="onBtnClicked('reply')">Reply</button>
<button class="btn btn-danger" onclick="onBtnClicked('delete')">Delete</button>
</div>`
});
我不希望在单击 'cancel(delete)' 按钮时关闭模式,只有在失去焦点或单击关闭按钮时才关闭。如何防止关闭?
默认取消按钮用于关闭对话框。您可以将自定义按钮添加为 html,并手动处理它们的点击事件,而不是为其他任务修改该按钮:(Run it live)
var onBtnClicked = (btnId) => {
// Swal.close();
alert("you choosed: " + btnId);
};
Swal.fire({
title: "What you want to do?",
icon: "warning",
showConfirmButton: false,
showCloseButton: true,
html: `
<p>select an action</p>
<div>
<button class="btn btn-primary" onclick="onBtnClicked('reply')">Reply</button>
<button class="btn btn-danger" onclick="onBtnClicked('delete')">Delete</button>
</div>`
});