English 中文(简体)
如何使jQuery对话框具有模态?
原标题:How to make jQuery dialog modal?

我在asp.net中使用jQuery对话框。它对我来说很好。问题是当我打开对话框时,我仍然可以使用父页功能。我不想那样。只需将对话框设置为模态,不应允许将焦点集中在父页上。

window.onload = function onloadFunction() {

        //setup edit person dialog
     $( #uploadPic ).dialog({
             autoOpen: false,
             draggable: true,
             title: "Upload Picture",
             open: function(type, data) {
                 $(this).parent().appendTo("form");
             }
         });
     }

有什么办法使它成为模态的吗?或者如果对话框失去焦点,自动关闭它?

请帮帮我。

最佳回答

使用

$( #uploadPic ).dialog({
         autoOpen: false,
         modal: true,
         draggable: true,
         title: "Upload Picture",
         open: function(type, data) {
             $(this).parent().appendTo("form");
         }
     });
 }

我刚刚在您的示例中添加了模态选项。

问题回答

阅读JQuery Ui对话框的文档:http://docs.jquery.com/UI/Dialog

存在一个名为Modal的选项,以下是文档中的一些示例:

使用指定的模式选项初始化对话框。

$( ".selector" ).dialog({ modal: true });

在初始化之后获取或设置模态选项。

//getter
var modal = $( ".selector" ).dialog( "option", "modal" );
//setter
$( ".selector" ).dialog( "option", "modal", true );




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签