From c3516e2449f4efb20e576f38f1a45a216c4cda24 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 19 Apr 2015 21:22:22 -0400 Subject: [PATCH] CRM-16275 - Fix repeating events checkbox hiding --- templates/CRM/Event/Form/Search/Common.tpl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index 47beaf83e0..832a5a5cd4 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -86,7 +86,17 @@ CRM.$(function($) { var recurringLabel = $('label[for=event_include_repeating_events]').html(); // Conditional rule for recurring checkbox function toggleRecurrigCheckbox() { - if ($(this).val() && $(this).select2('data')['api.RecurringEntity.getcount']) { + 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')['api.RecurringEntity.getcount']; + } else { + isRepeating = $(this).data('entityValue')[0]['api.RecurringEntity.getcount']; + } + } + if (isRepeating) { $('.crm-event-form-block-event_include_repeating_events').show(); $('label[for=event_include_repeating_events]').html(recurringLabel.replace('%1', $(this).select2('data').label)); } else { -- 2.25.1