我的html/javascript应用程序使用了一个模式弹出窗口,我使用sweet alert 2创建了这个弹出窗口。我们把这个叫做
“警报1”
.
alert1使用的是自定义html,在html中有一个按钮,我想触发另一个sweet alert 2模式弹出窗口,我们将调用这个按钮
“Alrt2”
。
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/我的问题:有没有办法有多个sweetAlert2警报?(即,从Alert1启动Alert2,然后关闭Alert2,将视图返回Alert1?