Level 29
http://datatables.net/tn/3 Check the link?
DataTables provides a destroy() method to destroy an old table, so you would be able to initialise a new one in its place.
Make sure the datatable is destroyed or haven't initialized yet.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How to re-initialize the DataTable using Javascript hooks?
I tried this but have an error
DataTables warning: table id=rolesTable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
This is my script
document.addEventListener("DOMContentLoaded", () => {
Livewire.hook('component.initialized', (component) => {
$('#rolesTable').DataTable({
"pagingType": "full_numbers",
});
})
Livewire.hook('element.initialized', (el, component) => {
$('#rolesTable').DataTable({
"pagingType": "full_numbers",
});
})
Livewire.hook('element.updating', (fromEl, toEl, component) => {
$('#rolesTable').DataTable({
"pagingType": "full_numbers",
});
})
Livewire.hook('element.updated', (el, component) => {
$('#rolesTable').DataTable({
"pagingType": "full_numbers",
});
})
});
Please or to participate in this conversation.