t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.85k forks source link

Multiple swal #974

Open jdechaseaux opened 2 years ago

jdechaseaux commented 2 years ago

Hello everebody, I have issues trying to display multiple swal.

Only the last swal is displayed. I tried many things with sweetalert and sweetalert2, without success. I tried use swal.queue but i have error like swal.queue doesnt exist.

Because i have situation where condition1 and condition2 are true or other situations ... And in fact i have more than 3 swal, but this is for the example.

Here is my code :

            if (condition1true) {
            swal({
                    title: "Erreur",
                    content: htmlContent,
                    icon: "error",
                    dangerMode: true,
                    className: "swalError"
                })
            }
        if (condition2true) {
            swal({
                    title: "Succes",
                    text: "text here...",
                    icon: "success"
                })
        }
        if (condition3true) {
                        swal({
                    title: "Succes",
                    text: "text here...",
                    icon: "success"
                })

        }

Thanks for your help

jm-taotao commented 2 years ago

but my project onley see the first, the next away flash across

lionralfs commented 2 years ago

You can do something like this: https://codepen.io/lionralfs/pen/mdqXWGX?editors=0010 which makes use of await to wait until a swal is closed, see docs.