From 8738dcd9886cdb5d91e481e11d0d1c730a9e9127 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Nov 2023 08:58:11 +0100 Subject: [PATCH] Bug 35284: Fix Vue tables Signed-off-by: David Cook Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 025b63ea38..d0e27a1462 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -63,7 +63,13 @@ var dataTablesDefaults = { }); if (settings.ajax) { - _dt_add_delay($("#"+tableId)); + let table_node = $("#" + tableId); + if ( typeof this.api === 'function' ) { + _dt_add_delay(this.api(), table_node); + } else { + let dt = $(table_node).DataTable(); + _dt_add_delay(dt, table_node); + } } } }; @@ -930,9 +936,8 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { // These keys must not launch filtering var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40); -function _dt_add_delay(table_node, delay_ms) { +function _dt_add_delay(table_dt, table_node, delay_ms) { - let dt = table_node.DataTable(); delay = (typeof delay == 'undefined') ? 500 : delay; var previousSearch = null; @@ -944,14 +949,14 @@ function _dt_add_delay(table_node, delay_ms) { if (blacklist_keys.indexOf(event.keyCode) != -1) { return; } else if ( event.keyCode == '13' ) { - dt.search($(input).val()).draw(); + table_dt.search($(input).val()).draw(); } else { let val = $(input).val(); if (previousSearch === null || previousSearch != val){ window.clearTimeout(timerId); previousSearch = val; timerId = window.setTimeout(function(){ - dt.search($(input).val()).draw(); + table_dt.search($(input).val()).draw(); }, delay); } } -- 2.39.5