Prevent SweetAlert to be closed on clicking outside the popup window

Saqib A. Azhar picture Saqib A. Azhar · Dec 11, 2017 · Viewed 54.3k times · Source

I am using Sweet Alert for a popup on my product view in an E-commerce Application with two buttons: one for going on cart View and another for reloading the view.

But when a user clicks outside of the popup, the popup window closes automatically. I've tried following properties to stop it to be closed but nothing works :

hideOnOverlayClick: false,
hideOnContentClick: false,
closeClick: false,
helpers: {
    overlay: { closeClick: false } 
}

Any help/suggestion is highly appreciated.

Thanks.

Answer

Halawa picture Halawa · Dec 20, 2017

If you are using Sweet Alert 2, you can use this configuration

allowOutsideClick: false

This should work.