From: Coleman Watts Date: Wed, 17 Sep 2014 04:07:32 +0000 (-0400) Subject: CRM-15278 - better handling of wysiwyg editors in popups X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=66663184e286093a2eb87adccfbacc618898bb62;p=civicrm-core.git CRM-15278 - better handling of wysiwyg editors in popups --- diff --git a/js/crm.ajax.js b/js/crm.ajax.js index aa6a87095f..29b011530e 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -257,7 +257,9 @@ return; } data.url = url; - that.element.trigger('crmBeforeLoad', data).html(data.content); + that.element.trigger('crmBeforeLoad', data); + that._beforeRemovingContent(); + that.element.html(data.content); that._handleOrderLinks(); that.element.trigger('crmLoad', data); that.options.crmForm && that.element.trigger('crmFormLoad', data); @@ -265,9 +267,21 @@ that._onFailure(); }); }, + // Perform any cleanup needed before removing/replacing content + _beforeRemovingContent: function() { + var that = this; + if (window.tinyMCE && tinyMCE.editors) { + $.each(tinyMCE.editors, function(k) { + if ($.contains(that.element[0], this.getElement())) { + this.remove(); + } + }); + } + this.options.crmForm && $('form', this.element).ajaxFormUnbind(); + }, _destroy: function() { this.element.removeClass('crm-ajax-container'); - this.options.crmForm && $('form', this.element).ajaxFormUnbind(); + this._beforeRemovingContent(); if (this._originalContent !== null) { this.element.empty().append(this._originalContent); } @@ -434,6 +448,11 @@ this.updateElement && this.updateElement(); }); } + if (window.tinyMCE && tinyMCE.editors) { + $.each(tinyMCE.editors, function() { + this.save(); + }); + } }, beforeSubmit: function(submission) { $.each(formErrors, function() {