$(document).ready(function(){ $('.tambah').click(function(){ ojisatrianiLoadingFadeIn(); $.loadmodal({ url: "{{ url($url_admin.'/barang/create') }}", id: 'responsive', dlgClass: 'fade', bgClass: 'primary', title: 'Tambah', width: 'whatever', modal: { keyboard: true, // any other options from the regular $().modal call (see Bootstrap docs) }, ajax: { dataType: 'html', method: 'GET', success: function(data, status, xhr){ ojisatrianiLoadingFadeOut(); }, }, }); }); }); $(document).on("click",".ubah",function() { ojisatrianiLoadingFadeIn(); var id = $(this).attr('barang-id'); $.loadmodal({ url: "{{ url($url_admin.'/barang') }}/"+ id +"/edit", id: 'responsive', dlgClass: 'fade', bgClass: 'warning', title: 'Ubah', width: 'whatever', modal: { keyboard: true, // any other options from the regular $().modal call (see Bootstrap docs) }, ajax: { dataType: 'html', method: 'GET', success: function(data, status, xhr){ ojisatrianiLoadingFadeOut(); }, }, }); }); function deleteData(id){ var csrf_token = $('meta[name="csrf-token"]').attr('content'); Swal.fire({ title: 'Apakah anda yakin ?', text: "untuk menghapus data ini..!", type: 'warning', showCancelButton: true, cancelButtonColor: '#d33', confirmButtonColor: '#3085d6', confirmButtonText: 'Ya', cancelButtonText: 'Tidak' }).then(function(result) { if (result.value) { $.ajax({ url: "{{ url($url_admin.'/barang') }}" + '/' + id, type: "POST", data: {'_method' : 'DELETE', '_token' : csrf_token}, success: function(data) { $('#datatable').DataTable().ajax.reload(); Swal.fire({ title: 'Berhasil...', text: 'Data telah dihapus..!', type: 'success', timer: 1500 }); }, error: function(){ Swal.fire({ title: 'Maaf...', text: 'Terjadi kesalahan. Silahkan coba lagi..!', type: 'error', timer: 1500 }); } }); } }); }