From 2659f33f6486c1229be9ce1d0033c323485aae11 Mon Sep 17 00:00:00 2001 From: poliphilochu Date: Wed, 25 Sep 2024 21:02:34 +0800 Subject: [PATCH] refs #41429. Add event listeners for crmaccordion and fix tokenInput issue --- js/jquery/jquery.crmaccordions.js | 6 ++++++ templates/CRM/Event/Form/Search/Common.tpl | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/js/jquery/jquery.crmaccordions.js b/js/jquery/jquery.crmaccordions.js index a290bdad9..abe6ea37f 100644 --- a/js/jquery/jquery.crmaccordions.js +++ b/js/jquery/jquery.crmaccordions.js @@ -38,6 +38,12 @@ $.fn.crmaccordions = function() { case "click": $wrapper.toggleClass("crm-accordion-open"); $wrapper.toggleClass("crm-accordion-closed"); + + if ($wrapper.hasClass("crm-accordion-open")) { + $wrapper.trigger("crmaccordion:open"); + } else { + $wrapper.trigger("crmaccordion:close"); + } return false; break; diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index 4576ec58d..0e2d35927 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -89,7 +89,17 @@ var eventUrl = "{/literal}{$dataURLEvent}{literal}"; var eventPrepopulate = ''; {/if} {literal} -cj("#event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText }); + +cj(".crm-accordion-wrapper").on("crmaccordion:open", function() { + if (!cj(".crm-accordion-wrapper #event_id ~ .token-input-list-facebook").length) { + cj(".crm-accordion-wrapper #event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText }); + } +}); +cj(document).ajaxSuccess(function(event, jqxhr, settings) { + if (jqxhr.responseText.indexOf('id="event_id"') != -1 && !cj("#event_id ~ .token-input-list-facebook").length) { + cj("#event_id").tokenInput( eventUrl, { prePopulate: eventPrepopulate, classes: tokenClass, hintText: hintText }); + } +}); var typeUrl = "{/literal}{$dataURLEventType}{literal}"; {/literal}