How to use Sweetarlet2 delete?

Viewed 33

I have an issue, I'm learning how to use sweetarlet2, I'm using spring project. I want to make a button that have arlet before delete it. here my HTML button.

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#delete" onclick="deleteArlet('+${ps.nama}+ ')"> delete </button> 

and here my js script.

<script>
                    function deleteArlet(id){
                    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.value) {
                            url: "/siswa/delete/"+ Id,
                                    data: { Id: Id }
                            Swal.fire(
                            'Deleted!',
                            'Your file has been deleted.',
                            'success'
                        )
                    }
                    })
                    }
1 Answers

try, if(result.isConfirmed) instead of if (result.value). that worked for me

Related