'how to have 2 swal templates open
is it possible to have two swal templates from sweeter alerts open at the same time?
picture this:
I am developing a blog and the page's creation is made on a swal template which inputs have a default value and the preview of the page is made on another swal and when this swal closes triggers the swal page creation template to appear but once this happens the swal page creation hasn't the user changes
soo how do I prevent the swal page creation from closing when I open the preview one
swal page creation template
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: true,
showConfirmButton: true,
showCancelButton: true,
template : '#add-user-page-template',
confirmButtonText: 'Confirmar',
cancelButtonText: 'Cancelar',
confirmButtonColor: '#0085c5',
cancelButtonColor: '#f04040',
customClass: 'my_pages_container',
height:'1000px',
willOpen: () => {
startSummernote();
$(`#title`).text("A minha página");
},
the swal template for the preview
$(document).on("click", "#preview", function() {
page_content = page_content = $($(".forSummerNote #summernote").summernote("code")).text();
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: true,
showConfirmButton: true,
template : '#preview-template',
confirmButtonText: 'Fechar',
confirmButtonColor: '#0085c5',
cancelButtonColor: '#f04040',
customClass: 'my_pages_preview_container',
height:'1000px',
willOpen: () => {
$("#preview_displayer").append(`
${page_content}
`);
},
}).then(swal => {
if(swal.isConfirmed)
{
$('#create_user_page').trigger('click');
}
})
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
