1

Can I manually show/hide device keyboard?

My application is behaving strangely if device keyboard is on display and, say, I hit next button then the CSS of jQuery Mobile is getting distorted. I am not getting any javascript or any other error in the console. Any help is appreciated.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Prerak Tiwari
  • 3,436
  • 4
  • 34
  • 64
  • http://stackoverflow.com/questions/9060658/how-to-use-phonegap-softkeyboard-plugin-for-android – Anup Sep 11 '14 at 13:39
  • What is "Next" button? in the keyboard, or a next button that navigates away to another page in your app? Please explain the scenario so that it could be reproduced. – Idan Adar Sep 11 '14 at 14:21
  • Its the 'Next' button on the page that navigates away to another page in app. – Prerak Tiwari Sep 11 '14 at 14:35

1 Answers1

2

I have used one of the suggestions in the following question (the one with 84 up votes...), and it worked well for me: iPad Safari - Make keyboard disappear

Lets assume you have an <input type="text" id="myInput" />.

So in your change page code you can do the following, which will first dismiss the keyboard and then perform the page navigation:

function changeToPage1() {
    $("#myInput").blur();
    $(':mobile-pagecontainer').pagecontainer('change','page1.html');
}

Tested in iOS Simulator but should work in Android as well.

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • I have made the changes. So far it looks good. Since it was a random issue, I cannot tell right now whether it worked or not. I will update the comment once I am done with the testing. – Prerak Tiwari Sep 11 '14 at 18:29
  • I think its working now. I have tested in 5 different devices. Thanks for the solution. – Prerak Tiwari Sep 11 '14 at 20:46