jQuery UI 1.7.1叠加模式下的关闭单击 [英] jQuery UI 1.7.1 Modal Close on Overlay Click
本文介绍了jQuery UI 1.7.1叠加模式下的关闭单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图覆盖jQuery UI模式对话框的默认行为,以在单击叠加层时关闭该框.第一次打开对话框并单击覆盖后,下面的代码将关闭对话框.当我再次打开对话框时,单击覆盖没有任何作用.我在这里错过了一个活动.有人可以指出我在做什么错吗?
I'm trying to override the default behavior of a jQuery UI modal dialog box to close the box when the overlay is clicked. The code I have below will close the dialog box after I open it for the first time and click on the overlay. When I open the dialog box again, clicking on the overlay does nothing. I am missing an event here. Can someone point out what I'm doing wrong here?
谢谢!
$(function(){
$('#production_schedule_dialog').dialog({
autoOpen: false,
width: 570,
modal: true,
closeOnEscape: true
});
$('#production_schedule_dialog_link').click(function(){
$('#production_schedule_dialog').dialog('open');
return false;
});
$(document).bind('click', dialogBlur);
});
var dialogBlur = function(event){
var target = $(event.target);
if (target.is('.ui-dialog') || target.parents('.ui-dialog').length) {
return;
}
$('.ui-dialog:visible').find('.ui-dialog-titlebar-close').trigger('click');
$(document).unbind('click', dialogBlur);
}
推荐答案
最简单的方法: http://www .ryanjeffords.com/blog/entry/closing-a-jquery-ui-dialog-when-the-dialog-loses-focus
添加此内容:
$('.ui-widget-overlay').live("click", function() {
//Close the dialog
$("#dialog").dialog("close");
});
这篇关于jQuery UI 1.7.1叠加模式下的关闭单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文