var that = this;
var url = this._formatUrl(this.options.url);
if (this.options.crmForm) $('form', this.element).ajaxFormUnbind();
- if (this._originalContent === null) {
- this._originalContent = this.element.contents().detach();
- }
if (this.options.block) this.element.block();
$.getJSON(url, function(data) {
if (that.options.block) that.element.unblock();
// Perform any cleanup needed before removing/replacing content
_beforeRemovingContent: function() {
var that = this;
+ // Save original content to be restored if widget is destroyed
+ if (this._originalContent === null) {
+ $('.blockUI', this.element).remove();
+ this._originalContent = this.element.contents().detach();
+ }
if (window.tinyMCE && tinyMCE.editors) {
$.each(tinyMCE.editors, function(k) {
if ($.contains(that.element[0], this.getElement())) {
// Create new dialog
if (settings.dialog) {
settings.dialog = CRM.utils.adjustDialogDefaults(settings.dialog);
- $('<div id="'+ settings.target.substring(1) +'"><div class="crm-loading-element">' + ts('Loading') + '...</div></div>').dialog(settings.dialog);
+ $('<div id="' + settings.target.substring(1) + '"></div>').dialog(settings.dialog);
+ }
+ if ($(settings.target).data('uiDialog')) {
$(settings.target)
.on('dialogclose', function() {
- if ($(this).attr('data-unsaved-changes') !== 'true') {
+ if (settings.dialog && $(this).attr('data-unsaved-changes') !== 'true') {
$(this).crmSnippet('destroy').dialog('destroy').remove();
}
})