最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to make jQuery dialog modal? - Stack Overflow

programmeradmin3浏览0评论

I am using jQuery dialog in asp. It is working fine for me. The problem is when I open the dialog box, I can still work parent page functionality. I don't want that. Just dialog to modal and should not allow focus on parent page.

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");
             }
         });
     }

Is there any way to make it modal? Or if lost focus on dialog box close it automatically?

Please help me out.

I am using jQuery dialog in asp.net. It is working fine for me. The problem is when I open the dialog box, I can still work parent page functionality. I don't want that. Just dialog to modal and should not allow focus on parent page.

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");
             }
         });
     }

Is there any way to make it modal? Or if lost focus on dialog box close it automatically?

Please help me out.

Share Improve this question edited Oct 15, 2010 at 18:58 Karim 18.6k14 gold badges63 silver badges71 bronze badges asked Oct 15, 2010 at 18:42 James123James123 11.7k70 gold badges198 silver badges355 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 16

Use

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

I have just added the modal option to your sample.

Read the documentation of JQuery Ui Dialog in: http://docs.jquery.com/UI/Dialog

Exist a Option called Modal, here is some samples from doc:

Initialize a dialog with the modal option specified.

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

Get or set the modal option, after init.

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

评论列表(0)

  1. 暂无评论