Search code examples
javascriptsweetalertsweetalert2

How after pressing the button to show another window? sweetalert2


How after pressing the button to show another window with success message? in sweetalert2


Solution

  • The easiest way to do that is to call another Swal inside the then. The simplest example is:

    swal.fire({
      title: 'Input Text',
      input: 'text'
    }).then(result => {
      swal.fire(`You wrote: ${result.value}`)
    })
    

    In this one, the value returned by the previous modal is re-used in the new one.

    You can find plenty of examples at https://sweetalert2.github.io/