Monday, 27 June 2022

Laravel get table row id by jquery , delete confirm

<button type="button" id="{{$value->id}}" class="action-btns1 deletebutton"
data-bs-toggle="tooltip" data-bs-placement="top" title="Delete">
<i class="feather feather-trash-2 text-danger"></i></a>



  $("body").on('click','.deletebutton', function(){

let id= $(this).attr('id');

const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
})

swalWithBootstrapButtons.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
reverseButtons: true
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url : "{{ route('admin.company.siteSetupDelete') }}",
type : 'POST',
data : {'_token':"{{ csrf_token() }}",id:id},
success :function(res)
{
swalWithBootstrapButtons.fire(
'Deleted!',
'Deleted Successfully.',
'success'
).then((result)=>{
setTimeout(function() {
location.reload();
}, 100);
});
setTimeout(function() {
location.reload();
}, 2000);
}
});
} else if (
/* Read more about handling dismissals below */
result.dismiss === Swal.DismissReason.cancel
) {
swalWithBootstrapButtons.fire(
'Cancelled',
'Record is safe',
'error'
)
}
})
});

No comments:

Post a Comment

Laravel Export data to csv

 use Illuminate\Http\Response; // Define a function to export data to CSV function exportToCSV($exportData, $columns) {     $filename = ...