我的HTML / Javascript应用程序使用我使用甜蜜警报2创建的模态弹出窗口 . 让我们称之为 "Alert1" .
Alert1正在使用自定义HTML,并且该HTML中有一个按钮,我想触发另一个甜蜜警报2模态弹出窗口,我们称之为 "Alert2" .
Alert2有两个选项 . “确认”或“取消”如果用户点击“取消”,我想返回Alert1 .
这是一个问题:Alert1的自定义HTML是可编辑的,因此,我不能只重新调用最初启动警报的代码,因为这将显示旧的HTML .
这是我尝试过的:
function clickButton(){ //This function will be attached to the button in Alert1
var currentSwal = document.getElementById('swal2-content').innerHTML;
swal({
title: "Confirm 'Remove Script Page'",
text:
"Are you sure you want to remove this page from the script?",
type: "warning",
showConfirmButton: true,
showCancelButton: true
}).then(function(dismiss) {
if (dismiss.dismiss == "cancel" || dismiss.dismiss == 'overlay') {
swal.close;
swal({
html: currentSwal,
showConfirmButton: false,
customClass: 'swal-extra-wide',
showCloseButton: true
});
} //end if
else {
//go ahead and delete the script page
} //end else
});
}//end function
我的上述解决方案不起作用 . 这有点难以解释,但基本上,HTML代码被破坏而且事情无法正常工作 .
TLDR/My question: Is there a way to have multiple SweetAlert2 alerts? (i.e. launch alert2 from alert1 and then close alert2, returning the view to alert1?