Sweetalert 2 more than 2 buttons. Don't close on deny

2.7k Views Asked by At

I'm using the example in this answer to display more than just 2 buttons on a swal. When the user clicks the deny button, I want to change something in the html of the swal without closing it. Right now, the swal is closed when the deny button is clicked. Where and how do I specify that the swal shouldn't close?

1

There are 1 best solutions below

0
On

I just added the preDeny parameter which allows to keep a modal opened by returning false:

Swal.fire({
  title: 'The "deny" button will not close me',
  showDenyButton: true,
  preDeny: () => {
    return false
  }
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script> 

Read more about preDeny: https://sweetalert2.github.io/#pre-deny