[英]Close a jQuery UI Dialog from an element inside of it?
Here's a quick question that's probably simpler than I'm thinking. 这是一个简单的问题,可能比我想的要简单。
I'm populating a jQuery UI dialog with the resulting html from an $.ajax() call. 我正在使用$ .ajax()调用生成的html填充jQuery UI对话框。 In certain cases that html includes a button that when clicked, I want to close the containing dialog. 在某些情况下,html包含一个按钮,单击该按钮时,我想关闭包含对话框。
Assuming that I don't know anything about the element that was specified to be the dialog using $("#element").dialog()
...(ie I have no idea what the "#element" selector is from the dialog's inner content) - What's the best way to close the dialog from an element clicked inside of it? 假设我不知道任何关于使用$("#element").dialog()
指定为对话框的$("#element").dialog()
。dialog $("#element").dialog()
...(即我不知道对话框中的“#element”选择器是什么内部内容) - 从内部单击的元素关闭对话框的最佳方法是什么?
使用closest()
$(this).closest('.ui-dialog-content').dialog('close');
Something like: 就像是:
$('a.close').click(function(e) {
$(this).closest('.dialog').dialog('close');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.