How to make jQuery dialog modal?

北慕城南 提交于 2019-11-28 07:22:34

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/3945123/how-to-make-jquery-dialog-modal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!