From e9d03a0c95cde370be908e7f03cbf9a2359ec8bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 18 Feb 2024 20:31:31 +0100 Subject: [PATCH] Fixed "Loading..." message on datatables with no content --- .../elements/datatables/datatables_controller.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assets/controllers/elements/datatables/datatables_controller.js b/assets/controllers/elements/datatables/datatables_controller.js index c53db751..f6c1f69f 100644 --- a/assets/controllers/elements/datatables/datatables_controller.js +++ b/assets/controllers/elements/datatables/datatables_controller.js @@ -145,6 +145,12 @@ export default class extends Controller { //Fix height of the length selector promise.then((dt) => { + + //Draw the rows to make sure the correct status text is displayed ("No matching records found" instead of "Loading...") + if (dt.data().length === 0) { + dt.rows().draw() + } + //Find all length selectors (select with name dt_length), which are inside a label const lengthSelectors = document.querySelectorAll('label select[name="dt_length"]'); //And remove the surrounding label, while keeping the select with all event handlers