Prevent SweetAlert to be closed on clicking outside the popup window

前端 未结 13 757
不知归路
不知归路 2021-02-01 04:40

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 vi

13条回答
  •  有刺的猬
    2021-02-01 04:49

    For sweetalert version < 2

    swal(
             "Records will be deleted permanently.",  //title
             "Do you want to delete records?",  //text
             "warning",  //icon
             {
                  closeOnClickOutside: false, // prevent close on click anywhere/outside
                  buttons: ["No", "Yes"], //with custom label
                  dangerMode: true,
             }
        ).then(ok => {
             if (ok) {
                  console.log("deleted")
             }
             else {
                  console.log("not deleted")
             }
        })
    

提交回复
热议问题