From 6af6e28c2c0d07d6c6793fb8f20e4d8a0098ab62 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 25 Apr 2015 12:16:28 -0600 Subject: [PATCH] CRM-16275 - Workaround for race conditions --- templates/CRM/Event/Form/Search/Common.tpl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index 8e1208f803..fa72a9f4f5 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -88,13 +88,11 @@ CRM.$(function($) { function toggleRecurrigCheckbox() { var isRepeating = false; if ($(this).val()) { - // In case select2 widget hasn't been initialized yet, we have to get the data from the dom - // FIXME: waiting for select2 initialization would be better, but not sure how - if ($(this).data('select2')) { - isRepeating = $(this).select2('data').extra.is_recur; - } else { - isRepeating = $(this).data('entityValue')[0].extra.is_recur; + // Workaround: In some cases this code gets called before the select2 initialization. + if (!$(this).data('select2')) { + $(this).crmEntityRef(); } + isRepeating = $(this).select2('data').extra.is_recur; } if (isRepeating) { $('.crm-event-form-block-event_include_repeating_events').show(); -- 2.25.1