CRM-16275 - Workaround for race conditions
authorColeman Watts <coleman@civicrm.org>
Sat, 25 Apr 2015 18:16:28 +0000 (12:16 -0600)
committerColeman Watts <coleman@civicrm.org>
Sat, 25 Apr 2015 18:16:28 +0000 (12:16 -0600)
templates/CRM/Event/Form/Search/Common.tpl

index 8e1208f803605f871504e23ea26e98333f4edd6e..fa72a9f4f595066f96e8df33473c150a4a081acb 100644 (file)
@@ -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();