我知道這個主題有一些已經存在的鏈接,但是我的問題沒有解決。所以我創建了一個新的。
首先,我需要關閉一個純jQuery UI對話框,當它在對話框外點擊時。所以首先我創建對話框,使用此代碼:關閉jquery ui對話框時點擊了對話框
<div id="login_panel" align=center style="display:none;">
<div id="add_predicts_popup1">
<div id="login_msg" align=center class="messagebox" style="display: none; width: 593px;height: 18px;" ></div>
<form name="log_form" id="log_form" method="get">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><h1>Enter Your Username and Password</h1></td><br></tr>
<tr><td><input name="txtuser" type="text" class="textpart" id="txtuser" onclick="closeMsg('login_msg')"/></td>
<td> </td>
</tr>
<tr><td><input name="txtpass" type="password" class="textpart" id="txtpass" /> </td>
<td><input name="btnlog" type="button" class="predict_button2" id="btnlog" value=" " /></td>
</tr>
<tr>
<td class="add_predicts_popup-style_01"><a href="#" onclick="register('register')">Register Now</a> l <a href="#" onclick="register('forgot')">Forget Password?</a></td>
</tr>
</table>
</form>
</div>
</div>
顯示對話框我用,
<script type='text/javascript'>
$('#log').click(function(){
$('#add_predicts_popup1').dialog({
modal:true,
width:608,
height:225,
title:"Log in"
});
});
</script>
<a href=\"#\" id=\"log\">Login</a>
這個工作很好,我加入了代碼以關閉盒狀,
$(window).click(function(event) {
if (($(event.target).closest('.ui-dialog')).length>0) {
// if clicked on a dialog, do nothing
return false;
} else {
// if clicked outside the dialog, close it
$('.ui-dialog-content:visible').dialog('close');
}
})
此後沒有顯示對話框。我在document.ready中添加了這個代碼。所以有人可以幫忙嗎?謝謝!。
這可能是你的'$(「#日誌」)。click'事件打開對話框和相同的點擊也觸發上的Sametime對話框關閉事件的情況。 –
謝謝!但我們怎麼能擺脫這一點,我只是嘗試添加一個支票$('#log')。點擊並讓你知道。 – VKGS
它工作時,日誌按鈕在關閉對話框代碼之前打開,因此它關閉框。所以我在檢查它不是「登錄」按鈕點擊後觸發了關閉對話框代碼,如下所示:if(event.target.id!='log'){$('。ui-dialog-content:visible')。對話框( '關閉'); } – VKGS