hapus kekayaan

parent 87c50032
......@@ -42,7 +42,7 @@
</td>
<td>
<a class="btn btn-warning" href="{{ route('kekayaanintelek.edit', ['kekayaanintelek' => encrypt($item->id)]) }}">Hapus</a>
<button class="btn btn-danger" type="button" onclick="hapus('form_kekayaan_{{ $loop->iteration }}')">Hapus</button>
<button class="btn btn-danger delete" type="button" data-target="form_kekayaan_{{ $loop->iteration }}">Hapus</button>
<form id="form_kekayaan_{{ $loop->iteration }}" action="{{ route('kekayaanintelek.destroy', ['kekayaanintelek' => encrypt($item->id)]) }}" method="POST">
{{ method_field('DELETE') }}
@csrf
......@@ -78,6 +78,27 @@
function hapus(id){
$('#'+id).submit();
}
$("body").on("click", ".delete", function (e) {
e.preventDefault();
var id = $(this).data('target');
Swal.fire({
title: "Apakah Anda Yakin?",
text: "Anda akan menghapus data ini!",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No"
}).then((result) => {
if (result.value) {
Swal.close();
$("#"+id).submit();
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire('Dibatalkan', 'Data batal dihapus', 'error');
}
});
});
</script>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment