当设备的(android)键盘处于活动状态时,jquery移动弹出窗口小部件不会移动

时间:2013-12-26 11:52:19

标签: android jquery-mobile cordova jquery-mobile-popup

我有一个jquery-mobile(1.3.1)+ phonegap应用程序,我在其中使用弹出窗口小部件(此应用程序适用于Android-any vresion)。此弹出窗口用于登录(它具有用户名,密码和“登录”按钮。每当我点击文本字段(用户名或密码)时,设备键盘会出现,但它与弹出窗口重叠。对于这种重叠,用户无法看到他们正在键入的内容,并且无法点击登录,除非键盘被最小化。这是我现在的代码 - 我已经使用了“data-position-to="window

<a href="#popupLogin" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" data-transition="pop">Done</a>
          <div data-role="popup" id="popupMenu" data-theme="a" >
            <div data-role="popup" id="popupLogin" data-overlay-theme="e" data-theme="a" class="ui-corner-all">
              <form>
                <div style="padding:10px 20px;" data-overlay-theme="b">
                  <h3>Please sign in</h3>
                  <label for="ppcOpremarks" class="ui-hidden-accessible">Remarks</label>
                  <textarea name="ppcOpremarks" id="ppcOpremarks" value="" placeholder="Remarks (if any)" data-theme="a" ></textarea>
                  <label for="un" class="ui-hidden-accessible">Username</label>
                  <input name="user" id="un" value="" placeholder="username" data-theme="a" type="text">
                  <label for="pw" class="ui-hidden-accessible">Password</label>
                  <input name="pass" id="pw" value="" placeholder="password" data-theme="a" type="password">
                  <a href="#menuPage">
                  <button type="submit" data-theme="a" data-icon="check" id="ppCheckDone" onClick="updateppc()">Sign-In</button>
                  </a> </div>
              </form>
            </div>
          </div>

如何让我的弹出窗口向上移动而不是与设备键盘重叠?

1 个答案:

答案 0 :(得分:4)

一旦输入字段集中在一个弹出窗口中,您就可以reposition

$("#popupLogin input, #popupLogin textarea").on("focus", function () {
  $("#popupLogin").popup("reposition", {
    y: 0 /* move it to top */
  });
});
  

<强> Demo