Prevent SweetAlert to be closed on clicking outside the popup window

前端 未结 13 769
不知归路
不知归路 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 05:02

    Regarding Sweet Alert 2 (More effective solution)

    Actually all answers here don't cover another way to dismiss the popup. And that's using keyboard. Especially the ESC key. In order to prevent that you would want to add two options instead of one.

    allowOutsideClick: false,
    allowEscapeKey: false,
    

    Quick example:

    Swal.fire({
      title: 'Do not dismiss!',
      icon: 'warning',
      showConfirmButton: false,
      allowOutsideClick: false,
      allowEscapeKey: false
    })

提交回复
热议问题