Please i want to delete a specific record based on its data-id as: data-id="delete-form-, but anytime i try it always returns the last record id and cant even delete.
below is my code
@forelse ($pos as $position)
<tr>
<td></td>
<td></td>
<td></a></td>
<td><a class="btn btn-warning" href=""><i class="fa fa-fw fa-lg fa-edit"></i>Edit</a></td>
<td>
<form data-id="delete-form-" action="" method="POST" style="display:none">
@csrf
@method('DELETE')
</form>
<a class="posSwal btn btn-sm btn-danger" href="" onclick="isConfirm()">
<i class="fa fa-fw fa-lg fa-times-circle"></i>Delete</a>
</td>
</tr>
@empty
<p>No Record available</p>
@endforelse
JavaScript
<script>
$('.posSwal').click(function(){
event.preventDefault();
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm) {
if (isConfirm) {
$("form").data("id").submit();
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire