mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-27 12:29:04 +08:00
Fixing javascript errors when closing dialog.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
}
|
||||
self.renderGraph(targetContainer, graph, self.settings.domOperations.append);
|
||||
self.element.find("a.add.start").removeClass("start").hide();
|
||||
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user