我正在尝试使用SweetAlert覆盖 javascript 确认框。我也对此进行了研究,但找不到合适的解决方案。
我正在这样confirm
使用
if (confirm('Do you want to remove this assessment') == true) {
//something
}
else {
//something
}
我正在使用它来覆盖
window.confirm = function (data, title, okAction) {
swal({
title: "", text: data, type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes", cancelButtonText: "No", closeOnConfirm: true, closeOnCancel: true
}, function (isConfirm) {
if (isConfirm)
{
okAction();
}
});
// return proxied.apply(this, arguments);
};
现在确认框已替换为 sweetalert。当用户单击Yes
按钮OK action
时,应调用确认框。但这不是电话
并且在上面的代码中发生了错误Uncaught TypeError: okAction is not a function
。
请建议我应该为覆盖确认框做些什么。