我正在尝试使用 AJAX 打开一个 jQuery 对话框。对话框的内容是从查询字符串加载的,并在表单标记内包含服务器控件。
我有一个 GridView,每行中的链接都会生成对话框。
第一次,对话框加载正常,但随后我需要在页面上打开另一个对话框,然后将加载第一个对话框。以后我无法打开相同的对话框。在 Firebug 中检查 DOM 会在页面末尾显示多个“容器”。我有一个 GridView,其中一列包含一个链接和一个空 div。我已经简化了控件 ID,因为它们被 ASP.NET 破坏了,但这是我的代码:
$('#linkId').click(function() {
$('#panelId').dialog({
autoOpen: true,
height: 600,
width: 680,
modal: true,
show: 'blind',
hide: 'blind',
title: 'More Information',
open: function () {
$(this).load(url).parent().appendTo("form");
},
close(){
// I've also tried using these (not both at the same time)
$(this).dialog('destroy').remove();// dialog never opens again
$(this).dialog('disable').remove();// dialog never opens again
}
});
return false;
});
});
我尝试将包含的函数添加到关闭事件中,但我得到了相同的效果。否则,当对话框最终打开时,一切正常(尽管页面末尾有多个对话框容器)。