Laravel Can't Confirm Delete With SweetAlert

- 1 answer

I have this problem with Sweetalert - I have the following code but the confirm modal is useless, as the request pass it and user don't even have time to decide. I have to figure it out to stop request executing and waits for user decision (Ok/Cancel).

Here's the code:

<a target="_blank" rel="nofollow noreferrer" href="{{route('notes.destroy', $note->id)}}" 
data-id="{{$note->id}}" onclick="confirmDelete('{{$note->id}}')" type="submit">
<span class="badge badge-danger">Delete</span></a>

and here's the jQuery (which I think it's the problem):

function confirmDelete(item_id) {
        title: "Are you sure?",
        text: "Once deleted, you will not be able to recover it!",
        icon: "warning",
        buttons: true,
        dangerMode: true,
    .then((willDelete) => {
        if (willDelete) {
            $('#' + item_id).submit();
        } else {
            swal("Cancelled Successfully");


In blade file:

<link rel="stylesheet" target="_blank" rel="nofollow noreferrer" href="">
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

<form id="delete_from_{{$note->id}}" method="POST" action="{{ route('post.destroy', $note->id) }}">
    {{ csrf_field() }}
    {{ method_field('DELETE') }}

    <div class="form-group">
        <a target="_blank" rel="nofollow noreferrer" href="javascript:void(0);" data-id="{{$note->id}}" class="_delete_data">
            <span class="badge badge-danger">Delete</span>

js code:

            var data_id = $(this).attr('data-id');
                title: 'Are you sure?',
                text: "You won't be able to revert this!",
                type: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, delete it!'
            }).then((result) => {

                if (result.value) {