Search code examples
javascripttoastsweetalertsweetalert2

SweetAlert open another alert with prevent closing previous alert


I want to open another alert along with the previous alert and prevent closing the previous alert, But the previous alert closes and new open. I used iziToast and I can do this but I want to use SweetAlert.

SweetAlert Example:

const swalToast = Swal.mixin({
  toast: true,
  iconColor: "white",
  customClass: { popup: "colored-toast" },
  showConfirmButton: false,
  timerProgressBar: true,
});

swalToast.fire({
  title: "One",
  position: "bottom",
  timer: 5000,
  icon: "info",
});

setTimeout(() => {
  swalToast.fire({
    title: "Two",
    position: "bottom",
    timer: 1500,
    icon: "info",
  });
}, 2000);

enter image description here

iziToast Example:

iziToast.info({
  position: "bottomCenter",
  title: "One",
  message: "",
  timeout: 5000,
});

setTimeout(() => {
  iziToast.info({
    position: "bottomCenter",
    title: "Two",
    message: "",
    timeout: 1500,
  });
}, 2000);

enter image description here


Solution

  • It is not possible to show more than one modal at a time, by design.

    SweetAlert open another alert with prevent closing previous alert

    Show two swal at same time

    2 or more modals at the same time