Writeoff/Resources/views/parameter/branches/_draw-scripts.js
2023-10-10 11:18:12 +07:00

38 lines
1.2 KiB
JavaScript

// Initialize KTMenu
KTMenu.init();
// Add click event listener to delete buttons
document.querySelectorAll('[data-kt-action="delete_row"]').forEach(function (element) {
element.addEventListener('click', function () {
Swal.fire({
text: 'Are you sure you want to remove?',
icon: 'warning',
buttonsStyling: false,
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No',
customClass: {
confirmButton: 'btn btn-danger',
cancelButton: 'btn btn-secondary',
}
}).then((result) => {
if (result.isConfirmed) {
Livewire.dispatch('delete', { id : this.getAttribute('data-kt-id') });
}
});
});
});
// Add click event listener to update buttons
document.querySelectorAll('[data-kt-action="update_row"]').forEach(function (element) {
element.addEventListener('click', function () {
Livewire.dispatch('update', { id : this.getAttribute('data-kt-id') });
});
});
// Listen for 'success' event emitted by Livewire
Livewire.on('success', (message) => {
// Reload the users-table datatable
LaravelDataTables['branch-table'].ajax.reload();
});