From 0929c6206da1f3b3862178daead9ae0c144c66b0 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Thu, 21 Nov 2024 09:58:20 +0100 Subject: [PATCH] fix: bug in datatables filter --- .../datatables/datatable_script.html | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/uniticket/uni_ticket_bootstrap_italia_template/templates/datatables/datatable_script.html b/uniticket/uni_ticket_bootstrap_italia_template/templates/datatables/datatable_script.html index de68690..d08ef5d 100644 --- a/uniticket/uni_ticket_bootstrap_italia_template/templates/datatables/datatable_script.html +++ b/uniticket/uni_ticket_bootstrap_italia_template/templates/datatables/datatable_script.html @@ -151,24 +151,28 @@ } }); - $('#search_year, #search_box, #search_category').on('keypress', function () { + $('#search_year, #search_box, #search_category').on('change keypress', function () { + var year = $('#search_year').val(); + var category = $('#search_category').val(); + if (typeof category === 'undefined'){ + category = ""; + } + var structure = $('#search_structure').val(); + if (typeof structure === 'undefined'){ + structure = ""; + } + var args = '{"year": "'+year+'", '+ + '"category": "'+category+'", '+ + '"structure": "'+structure+'"}'; + if (event.key === "Enter") { - var year = $('#search_year').val(); - var category = $('#search_category').val(); - if (typeof category === 'undefined'){ - category = ""; - } var text = $('#search_box').val(); - var structure = $('#search_structure').val(); - if (typeof structure === 'undefined'){ - structure = ""; - } var args = '{"year": "'+year+'", '+ '"text": "'+text+'", '+ '"category": "'+category+'", '+ '"structure": "'+structure+'"}'; - datatable.search(args).draw(); } + datatable.search(args).draw(); } );