From c02f8fc415416b58fed4803ee5d7867b8efd76fd Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 6 Jan 2014 16:56:07 -0800 Subject: [PATCH] CRM-10693 - crmSnippet - restore original content on destroy --- js/Common.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/Common.js b/js/Common.js index 9493cdcebb..77a7f337d1 100644 --- a/js/Common.js +++ b/js/Common.js @@ -815,6 +815,7 @@ CRM.validate = CRM.validate || { block: true, crmForm: null }, + _originalContent: null, _originalUrl: null, isOriginalUrl: function() { var @@ -890,7 +891,11 @@ CRM.validate = CRM.validate || { return; } data.url = url; - that.element.trigger('crmBeforeLoad', data).html(data.content); + that.element.trigger('crmBeforeLoad', data); + if (that._originalContent === null) { + that._originalContent = that.element.contents().detach(); + } + that.element.html(data.content); that._handleOrderLinks(); that.element.trigger('crmLoad', data); that.options.crmForm && that.element.trigger('crmFormLoad', data); @@ -900,6 +905,9 @@ CRM.validate = CRM.validate || { }, _destroy: function() { this.element.removeClass('crm-ajax-container'); + if (this._originalContent !== null) { + this.element.empty().append(this._originalContent); + } } }); @@ -915,8 +923,7 @@ CRM.validate = CRM.validate || { width: '65%', height: parseInt($(window).height() * .75), close: function() { - $(this).dialog('destroy'); - $(this).remove(); + $(this).dialog('destroy').remove(); } }; } -- 2.25.1