Domanda

I have a jquery-mobile (1.3.1) + phonegap app in which I am using a pop-up widget (This app is for Android-any vresion). This popup is for sign-in (it has Username, Password and a "Sign-in" button. Whenever I click on a text-field (either Username or Password) the device keyboard comes-up but it overlaps with the popup. Because of this overlap, users cannot see what they are typing, and cannot click on Sign-In unless the keyboard is minimized. Here is the code what I have now - I've already used "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>

How to make my popup move towards upward direction instead of overlapping with the device keyboard?

È stato utile?

Soluzione

You can reposition a popup once an input field is focused within it.

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

Demo

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top