jQuery UI对话框不居中

Mar*_*ger 3 jquery jquery-ui jquery-ui-dialog

我正在使用jQuery,我正在将内容加载到div中,然后将其显示为对话框.但是,它不是对话框的中心.

有没有人有办法解决吗?

码:

function Core_Load_Register()
{
    $("body").append("<div id='Register_Popup'></div>");
    $("#Register_Popup").load("index.php?section=FrontPage&page=Register&nogui=true");
    $("#Register_Popup").dialog({
        modal: true,
        height: "auto",
        width: "auto",
        buttons: 
        {
            "Register New Account":
            function() 
            {

            },

            "Cancel":
            function()
            {
                $(this).dialog("close");
            }
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

示例截图:

jQuery对话框不以中心为例http://oi54.tinypic.com/nlznl4.jpg

Eri*_*ips 9

由于您的内容是动态的,请尝试等待load命令先完成.

$("#Register_Popup")
  .load("index.php?section=FrontPage&page=Register&nogui=true", 
  function()
  {
    $("#Register_Popup").dialog({ 
      modal: true, 
      height: "auto", 
      width: "auto", 
      buttons:  
      { 
        "Register New Account": 
        function()  
        { 

        }, 

        "Cancel": 
        function() 
        { 
            $(this).dialog("close"); 
        } 
      } 
  }); 
});
Run Code Online (Sandbox Code Playgroud)