Skip to content

Instantly share code, notes, and snippets.

@marvinhosea
Last active April 24, 2021 10:10
Show Gist options
  • Save marvinhosea/52dd13a5263d6ac5f6856f1d984d50a5 to your computer and use it in GitHub Desktop.
Save marvinhosea/52dd13a5263d6ac5f6856f1d984d50a5 to your computer and use it in GitHub Desktop.
#Blade
<form id="delete-company" action="{{ route('company.destroy', $company->id) }}" method="post">
{{csrf_field()}}
{{method_field('delete')}}
<button type="button" class="btn btn-xs btn-primary" data-toggle="modal" data-target="#agent{{$company->id}}">Edit</button>
<button type="button" class="btn btn-danger btn-xs" onclick="confirmDelete('delete-company')">delete</button>
</form>
<script>
function confirmDelete(item_id) {
swal({
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");
}
});
}
</script>
@vhgah
Copy link

vhgah commented Apr 24, 2021

<script type="text/javascript">
function deleteFunc(id){
	Swal.fire({
		title: 'Cảnh báo!',
		text: "Bạn chắc chắn muốn xóa này?",
		icon: 'warning',
		showCancelButton: true,
		confirmButtonColor: '#3085d6',
		cancelButtonColor: '#d33',
		confirmButtonText: 'Đồng ý!'
	}).then((result) => {
		if (result.value) {
			$.ajax({
				type:"DELETE",
				url: "{{ url('khachhang/{id}') }}",
				data: { id: id },
				dataType: 'json',
				success: function(res){
					var oTable = $('#data-table').dataTable();
					oTable.fnDraw(false);
				}
			});
		} else {
			swal("Cancelled Successfully");
			return false;
		}
	});
}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment