Fixing javascript errors when closing dialog.

This commit is contained in:
Sipke Schoorstra
2014-10-29 23:13:34 -07:00
parent 49c18d82c2
commit 372e56a2af
3 changed files with 29 additions and 17 deletions

View File

@@ -43,6 +43,7 @@
}
self.renderGraph(targetContainer, graph, self.settings.domOperations.append);
self.element.find("a.add.start").removeClass("start").hide();
dialog.close();
}
});

View File

@@ -1,6 +1,15 @@
(function ($) {
var closedDialogs = [];
var disposeClosedDialogs = function() {
$.each(closedDialogs, function() {
this.dispose();
});
};
var Dialog = function (templateElementSelector) {
var self = this;
this.template = $(templateElementSelector);
this.root = null;
this.element = null;
@@ -9,6 +18,8 @@
this.isVisible = false;
this._title = this.template.find(".title").html();
disposeClosedDialogs();
this.title = function (value) {
var titleElement = this.root.find(".title");
this._title = value;
@@ -37,8 +48,9 @@
$(document).on("keyup", onKeyUp);
this.frame.element.on("load", function(e) {
updateDialog(self.frame.getDocument());
this.frame.element.on("load", function (e) {
if(self.isVisible)
updateDialog(self.frame.getDocument());
});
}
@@ -47,14 +59,11 @@
if (this.root) {
$(window).off("resize", resizeIFrame);
this.root.remove();
this.root.hide();
}
this.root = null;
this.element = null;
this.frame = null;
$(document).off("keyup", onKeyUp);
closedDialogs.push(self);
};
this.load = function (url, data, method) {
@@ -74,6 +83,11 @@
});
};
this.dispose = function() {
if (this.root)
this.root.remove();
};
this.setHtml = function(html) {
this.frame.element.hide();
this.view.show();

View File

@@ -30,16 +30,13 @@
using (Script.Foot()) {
<script type="text/javascript">
jQuery(function () {
// Adding a small delay to prevent certain third party scripts from throwing up when the window is destroyed.
setTimeout(function () {
window.parent.currentDialog.trigger("command", {
command: "@command",
element: {
typeName: "@Model.TypeName",
state: "@Url.Encode(Model.ElementState)"
}
});
}, 50);
window.parent.currentDialog.trigger("command", {
command: "@command",
element: {
typeName: "@Model.TypeName",
state: "@Url.Encode(Model.ElementState)"
}
});
});
</script>
}