diff --git a/app/assets/javascripts/modal.js b/app/assets/javascripts/modal.js index f15beb0784..9a1f03630a 100644 --- a/app/assets/javascripts/modal.js +++ b/app/assets/javascripts/modal.js @@ -12,6 +12,7 @@ var ModalHelper = (function() { var ModalHelper = function() { + this._firstLoad = true; var modalHelper = this; var modalDiv, modalIframe; @@ -33,7 +34,7 @@ var ModalHelper = (function() { var body = jQuery(document.body); // whatever globals there are, they need to be added to the // prototype, so that all ModalHelper instances can share them. - if (ModalHelper.prototype.done !== true) { + if (ModalHelper._done !== true) { // one time initialization modalDiv = jQuery('
').css('hidden', true).attr('id', 'modalDiv'); modalIframe = modalHelper.writeIframe(modalDiv); @@ -46,7 +47,7 @@ var ModalHelper = (function() { // close when body is clicked body.on("click", ".ui-widget-overlay", jQuery.proxy(modalHelper.close, modalHelper)); - ModalHelper.prototype.done = true; + ModalHelper._done = true; } else { modalDiv = jQuery('#modalDiv'); modalIframe = jQuery('#modalIframe'); @@ -69,10 +70,6 @@ var ModalHelper = (function() { this.hideLoadingModal(); this.loadingModal = false; - //add closer - modalDiv.parent().prepend('
').click(jQuery.proxy(this.close, this)); - jQuery('.ui-dialog-titlebar').hide(); - modalDiv.data('changed', false); //tweak body. @@ -184,6 +181,14 @@ var ModalHelper = (function() { } }); + if (this._firstLoad) { + //add closer + modalDiv.parent().prepend('
').click(jQuery.proxy(this.close, this)); + jQuery('.ui-dialog-titlebar').hide(); + + this._firstLoad = false; + } + this.loading(); modalIframe.attr("src", url);