input focus in jquery mobile, but keyboard doesn't appear

后端 未结 5 2230
轻奢々
轻奢々 2020-12-30 22:33

I\'m using jquery,jquery mobile and phonegap. I want to show the keyboard one this page with input type=\"text\".

    
5条回答
  •  轮回少年
    2020-12-30 22:48

    None of the previous solutions worked for me. However, I noticed that $('textarea').focus().select(); worked after I access the page a second time. So, I force the jquery mobile to data-prefetch my comment box page.

    This is my generic JQM initialization code (which doesn't work without 'data-prefetch'):

    $('#comment-box-page').live('pageshow', function () {
       $('textarea').focus().select();
    });
    

    On the list page there is a fake image of a small text box, that redirects to comment-box.html, which is just a big test area with post and cancel buttons.

            
    
    • data-prefetch is what is making the difference. When you click the link, the page will behave as it was the second time you visited it, enabling focus and bringing the keyboard up.

提交回复
热议问题