+ var recurringLabel = $('label[for=event_include_repeating_events]').html();
+ // Conditional rule for recurring checkbox
+ function toggleRecurrigCheckbox() {
+ var isRepeating = false;
+ if ($(this).val()) {
+ // 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();
+ $('label[for=event_include_repeating_events]').html(recurringLabel.replace('%1', $(this).select2('data').label));
+ } else {
+ $('.crm-event-form-block-event_include_repeating_events').hide().find('input').prop('checked', false);
+ }
+ }
+ $('#event_id').each(toggleRecurrigCheckbox).change(toggleRecurrigCheckbox);
+