jquery-mobileibm-mobilefirstworklight-runtime

Manually Show/Hide Device keyboard in JavaScript


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.


Solution

  • 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.