【问题标题】:jQuery UI Dialog Box PositionjQuery UI 对话框位置
【发布时间】:2014-12-01 13:06:24
【问题描述】:

我有一个比屏幕高度高的表格。当用户提交表单时,会弹出一个对话框并通过 AJAX 询问并确认他们的密码。我的问题是对话框总是出现在屏幕的最底部,即使使用下面的 jQuery 代码也是如此,我相信这是正确的。

<div id="passConfirmBox">
    <p class="confirmError">Invalid password, try again</p>
    <p><input type="password" name="passwordField" id="passwordField" value=""></p>
    <button type="button" id="passConfirmButton">Confirm Password</button>
</div>

var passConfirm = $("#passConfirmBox").dialog( { title: "Confirm Your Password", 
autoOpen: false, position: { my: "center", at: "center", of : window } });

【问题讨论】:

    标签: javascript jquery html jquery-ui jquery-ui-dialog


    【解决方案1】:

    试试这个:

    var myPos = { my: "center top", at: "center top+150", of: window };
    

    你的完整脚本:

     <script>
        $(function() {
            var myPos = { my: "center top", at: "center top+150", of: window };
        var passConfirm = $("#passConfirmBox").dialog( { title: "Confirm Your Password", 
            autoOpen: true, position: myPos});// autoOpen is set to true to test you can change it to your use.
    
        });
    
        </script>
      </head>
    
      <body>
      <div id="passConfirmBox">
        <p class="confirmError">Invalid password, try again</p>
        <p><input type="password" name="passwordField" id="passwordField" value=""></p>
        <button type="button" id="passConfirmButton">Confirm Password</button>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-13
      • 2011-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多