dimanche 2 avril 2017

Laravel - Always deleting the last value of the page when deleting anything in the page

This is my Form :

<form class="myForm" action="/videos/" method="post">

<a href="/videos//edit" class="btn btn-info">Edit</a>

       <button type="button" class="btn btn-danger delete">Delete</button>
            
            
</form>

Here is the js with sweetalert :

$('.delete').on('click', function(){
  swal({   
    title: "Are you sure?",
    text: "You will not be able to recover this lorem ipsum!",
    type: "warning",   
    showCancelButton: true,   
    confirmButtonColor: "#DD6B55",
    confirmButtonText: "Yes, delete it!", 
    closeOnConfirm: false 
  }, 
       function(){   
    $(".myForm").submit();
  });
})

This always deletes the last row from the page i.e it takes the last value on the page and deletes even if we selected some other value

But this code works:

$(".myForm").on("submit", function(){
        return confirm("Do you want to delete this item?");
    });

Since it does not looks good therefore sweet alert and the same problem is with modal pop up.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire