From 159e5c6bca0b6e797e43c1c00452cb563b51cc85 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Nov 2023 08:58:41 +0100 Subject: [PATCH] Bug 35284: Add throttling to column filters Signed-off-by: David Cook Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5220dd6004ff34d29c29e1e139d6d17ccecff9b4) Signed-off-by: Fridolin Somers --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index c20915fd60..a1a8d9be67 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -906,13 +906,17 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { } } + var search = $.fn.dataTable.util.throttle( function ( i, val ) { + table_dt + .column( i ) + .search( val ) + .draw(); + }, 1000 ); + $( input_type, this ).on( 'keyup change', function () { if ( table_dt.column(i).search() !== this.value ) { if ( input_type == "input" ) { - table_dt - .column(i) - .search( this.value ) - .draw(); + search(i, this.value) } else { table_dt .column(i) -- 2.39.5