CRM-15346 - Trigger Drupal.detachBehaviors when removing dynamic content
authorColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 18:04:04 +0000 (14:04 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 18:04:04 +0000 (14:04 -0400)
js/crm.ajax.js
js/crm.drupal.js

index cb9553dd6089c45bc67f4187a4147f1330afe428..8aff1bbdb7eb8570ec8e8c69257cb06746fd08b8 100644 (file)
       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);
index 0d8dadcf9e423416e3f60c60b099d597f81c522c..7699e6e9d9294498c45d587acaeb4e21e7f3ebc3 100644 (file)
@@ -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');