From c231d052a2ec3f13eaba9dfba1b161de3789e480 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 | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 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..8fe3076 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,25 @@ } }); - $('#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 text = "" 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(); + text = $('#search_box').val(); } + var args = '{"year": "'+year+'", '+ + '"text": "'+text+'", '+ + '"category": "'+category+'", '+ + '"structure": "'+structure+'"}'; + datatable.search(args).draw(); } );