From: Coleman Watts Date: Wed, 22 Oct 2014 18:04:04 +0000 (-0400) Subject: CRM-15346 - Trigger Drupal.detachBehaviors when removing dynamic content X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=af8c0ebe0d212170738034e6f8ab3ba2641c46b0;p=civicrm-core.git CRM-15346 - Trigger Drupal.detachBehaviors when removing dynamic content --- diff --git a/js/crm.ajax.js b/js/crm.ajax.js index cb9553dd60..8aff1bbdb7 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -280,7 +280,7 @@ this.options.crmForm && $('form', this.element).ajaxFormUnbind(); }, _destroy: function() { - this.element.removeClass('crm-ajax-container'); + this.element.removeClass('crm-ajax-container').trigger('crmUnload'); this._beforeRemovingContent(); if (this._originalContent !== null) { this.element.empty().append(this._originalContent); diff --git a/js/crm.drupal.js b/js/crm.drupal.js index 0d8dadcf9e..7699e6e9d9 100644 --- a/js/crm.drupal.js +++ b/js/crm.drupal.js @@ -5,6 +5,9 @@ CRM.$(function($) { // This is drupal's old-school way of listening for 'load' type events. It has to be called manually. Drupal.attachBehaviors(this); }) + .on('crmUnload', function() { + Drupal.detachBehaviors(this); + }) .on('dialogopen', function(e) { // D7 hack to get the toolbar out of the way (CRM-15341) $('#toolbar').css('z-index', '100');