SweetAlert2 Confirm Dialog Not Working Properly In Onclick
How to fix the sweetalert2 confirm dialog not working properly in onclick event button? I have a modal popup, for CRUD operations before submitting sweetalert2 confirm dialog is tr
Solution 1:
Try this
<button type="submit" class="btn btn-success btn-flat" onclick="submitResult(event)"><i class="far fa-check-circle"></i> Save Changes</button>
....
function submitResult(e) {
    e.preventDefault();
    Swal.fire({
        title: 'Are you sure?',
        text: "You won't be able to revert this!",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: 'Yes, delete it!'
    }).then((result) => {
        if (result.isConfirmed) {
            Swal.fire(
                'Deleted!',
                'Your file has been deleted.',
                'success'
            )
            document.getElementById("EditForm").submit();
        }
    })
}
Post a Comment for "SweetAlert2 Confirm Dialog Not Working Properly In Onclick"