From 0ee5f635d8e001e005e099d5f0afa8c2c2562f86 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 | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 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..aa44fef 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,24 @@ } }); - $('#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 = ""; + } 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(); } + var args = '{"year": "'+year+'", '+ + '"text": "'+text+'", '+ + '"category": "'+category+'", '+ + '"structure": "'+structure+'"}'; + datatable.search(args).draw(); } );