diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 12f0cd7f56..e03c0c2a3e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -864,17 +864,24 @@ 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(); - }, 500); + function delay(callback, ms) { + var timer = 0; + return function () { + var context = this, args = arguments; + clearTimeout(timer); + timer = setTimeout(function () { + callback.apply(context, args); + }, ms || 0); + }; + } - $( input_type, this ).on( 'keyup change', function () { - if ( table_dt.column(i).search() !== this.value ) { - if ( input_type == "input" ) { - search(i, this.value) + $(input_type, this).on('keyup change', (delay(function () { + if (table_dt.column(i).search() !== this.value) { + if (input_type == "input") { + table_dt + .column(i) + .search(this.value) + .draw(); } else { table_dt .column(i) @@ -882,7 +889,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { .draw(); } } - } ); + }, 500))); } else { $(this).html(''); }