我想结束我的弹出,如果我点击以外的任何地方popupbox的
$( “弹出”)。对话框({jQuery UI的对话框关闭上点击任何地方
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="css/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".popup").dialog({
autoOpen: false,
draggable: true,
title: "Add New Person",
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
$("#body1")
.bind(
'click',
function (e) {
if (
jQuery('.popup').dialog('isOpen')
&& !jQuery(e.target).is('.ui-dialog, a')
&& !jQuery(e.target).closest('.ui-dialog').length
) {
jQuery('.popup').dialog('close');
}
}
);
});
function showDialog(id) {
$('#' + id).dialog("open");
}
function closeDialog(id) {
$('#' + id).dialog("close");
}
</script>
</head>
<body id="body1">
<input type="button" onclick="showDialog('pop101');" value="Popup1" />
<input type="button" onclick="showDialog('pop102');" value="Popup2" />
<input type="button" onclick="showDialog('pop103');" value="Popup3" />
<div style="background: green" id='pop101' class="popup">
</div>
<div style="background: orange" id='pop102' class="popup">
</div>
<div style="background: blue" id='pop103' class="popup">
</div>
</body>
</html>
点击buttoon到打开一个弹出窗口,当我们点击弹出窗口外,我想要弹出窗口,怎么可能?
可能的复制http://stackoverflow.com/questions/2554779/jquery-ui-close-dialog-when-clicked-outside – hsalama
其实我试图从这里和那里的东西(stackoverlflow),我无法解决这就是为什么我张贴:) – vir
你是否使用这种模式?即在打开时阻止对底层页面的所有访问? – hsalama