cloudlog/assets/js/sections/station_logbooks.js
Peter Goodhall 93ba9f7337 Initialize DataTable only when data rows exist
Added a check to ensure DataTable is initialized only if the table contains actual data rows and not just a 'no data' message. This prevents unnecessary initialization and potential errors when the table is empty.
2025-11-22 14:31:46 +00:00

22 lines
671 B
JavaScript

$(document).ready( function () {
$('#station_logbooks_table').DataTable({
"stateSave": true,
"language": {
url: getDataTablesLanguageUrl(),
}
});
} );
$(document).ready( function () {
// Only initialize DataTable if there are actual data rows (not just the "no data" message)
var table = $('#station_logbooks_linked_table');
if (table.find('tbody tr').length > 0 && table.find('tbody tr td[colspan]').length === 0) {
table.DataTable({
"stateSave": true,
"paging": true,
"language": {
url: getDataTablesLanguageUrl(),
}
});
}
} );