From 5296f678a39e69b7579b61219063903be2284864 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 10 Jan 2024 12:20:28 +0000 Subject: [PATCH] Bug 35329: (follow-up) Trigger Select2 upon modal open If we wait until the modal is visible Select2 can correctly calculate the width needed for the Sort 1 and Sort 2 dropdowns. Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize --- .../intranet-tmpl/prog/en/includes/patron-search.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 931fca48bf1..85980b6dc3c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -239,9 +239,15 @@ var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; [% END %] - $(document).ready(function() { + $(document).on("shown.bs.modal", function(){ $('select[name="sort1_filter"]').select2({allowClear:true}); $('select[name="sort2_filter"]').select2({allowClear:true}); + }).on("hidden.bs.modal", function(){ + ["sort1_filter", "sort2_filter"].forEach(function(item){ + if( $('select[name=' + item + ']').data("select2") ){ + $('select[name=' + item + ']').select2("destroy"); + } + }); }); -- 2.34.1