我是JQuery的新手,所以请原谅这个明显的粗俗标题。我真的不知道该如何描述这个问题,但基本上,在打开对话框之后,我看到的有关firebug的内容有很多:
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all " style="display: none; position: absolute; overflow: hidden; z-index: 1006; outline: 0px none; height: auto; width: 400px; top: 137px; left: 436px;" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-3">
至少有100个,我可以看到,每次我打开一个对话框。
有办法阻止这件事吗?我注意到我打开的对话框越多,系统就变得越慢。我不确定这就是原因,但我很怀疑。
发布于 2013-09-27 18:51:32
创建jquery对话框会带来很多开销,jquery用于各种类型的对话,如所有方向的大小调整、插件转换的对话框本身(供稍后重用)等等。因此,如果您每次需要销毁对话框时都要创建该对话框。一旦对话框上的关闭事件完成,您就需要销毁它们,您可以通过订阅关闭对话事件列出这些事件。
就像这样:
$(':input').on('click', function () {
$('<div title="Basic dialog" style="display:none"> <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the x icon.</p></div>').dialog({
close: function (event, ui) {
$(this).dialog('destroy'); //destroy it on every close
}
});
});
https://stackoverflow.com/questions/19062501
复制相似问题