From af8c0ebe0d212170738034e6f8ab3ba2641c46b0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 22 Oct 2014 14:04:04 -0400 Subject: [PATCH] CRM-15346 - Trigger Drupal.detachBehaviors when removing dynamic content --- js/crm.ajax.js | 2 +- js/crm.drupal.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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'); -- 2.25.1