Files
opensem/resources/views/components/js/datatable.blade.php
2020-07-26 16:51:45 +02:00

52 lines
1.2 KiB
PHP

{{$dataTable->scripts()}}
<script>
$('#{{ $model }}-table').on( 'draw.dt', function () {
var table = window.LaravelDataTables["{{ $model }}-table"];
$('.btn-edit').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
url = '{{ $route }}' + '/edit/' + id;
console.log(url);
openURL(url);
});
$('.btn-show').off('click').click(function(e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
url = '{{ $route }}' + '/show/' + id;
openURL(url);
});
$('.btn-del').off('click').click(function (e) {
e.preventDefault();
// var id = table.row(this).id();
var id = $(this).data('id');
bootbox.confirm("{{ __('admin.confirmdelete') }}", function (result) {
if (result === false) return;
$.ajax({
url: '{{ $route }}' + '/destroy/' + id,
method: 'delete',
headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'},
success: function(){
// line.remove();
table.draw();
growl("{{ __('admin.deletesuccess') }}", 'success');
}
});
});
});
});
// datatablesHelper.getDatatableLength('{{ $model }}', 34);
</script>