Search code examples
twitter-bootstrapmodal-dialogbootstrap-modalsweetalertsweetalert2

How to call a bootstrap modal after sweetAlert2's confirm clicked?


I want to open a modal after clicking the confirm button of SweetAlert2. But nothing happens after clicking it.

I found this one and only, which is the same issue I'm having now.

I've tried the same, but it doesn't work, maybe because he had the oldest version of SweetAlert.

Anyway, here's my code:

        Swal.fire({
            title: 'Process Selected Item(s)?',
            icon: 'warning',
            allowOutsideClick: false,
            allowEscapeKey: false,
            allowEnterKey: false,
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'YES!',
            cancelButtonText: 'No, cancel!',
            reverseButtons: true,
            allowOutsideClick: false
        }).then((result) => {
            if (result.isConfirmed) {
                $('#processItemsModal').modal('show');
            } else{
                Swal.fire(
                'Cancelled',
                'No changes has been made!',
                'error'
                )
            }
        })

What do you think I am missing here?

TIA


Solution

  • Solved my issue since I am using Bootstrap v5.

    Instead of this;

    $('#processItemsModal').modal('show');
    
    

    I used this;

    
    let myModal = new bootstrap.Modal(document.getElementById('processItemsModal'), {});
    myModal.show();