输入焦点在jQuery移动,但键盘不出现 [英] input focus in jquery mobile, but keyboard doesn't appear

查看:355
本文介绍了输入焦点在jQuery移动,但键盘不出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery,jquery手机和phonegap。
我想显示键盘一个这个页面与输入type =text。

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

    <section id="page1" data-role="page">
        <header data-role="header">
            <h1>jQuery Mobile</h1>
        </header>
        <div data-role="content" class="content">

            <input type="text" placeholder="입력하세요" />
        </div>

    </section>

我的脚本是

        $(document).ready(function(){
            $('input').select();
            $('input').focus();
        });

文本字段被聚焦但键盘不显示,并且当输入类型=文本。我如何强制在javascript或使用phonegap插件启动键盘?

The text field is focused but the keyboard is not show, and It is lauched when input type="text" is clicked. How can I force to launch the keyboard in javascript or using phonegap plugin?

推荐答案

但是,我注意到$('textarea')。focus()。select();工作后我访问的页面第二次。

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.

这是我的通用JQM初始化代码(不能在没有'data-prefetch'的情况下工作。 ):

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

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

在列表页面上有一个小的文本框的假图像,重定向到注释框.html,它只是一个带有post和cancel按钮的大测试区。

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.

        <div data-role="footer" data-position="fixed" data-theme="b" data-tap-toggle="false">
        <div data-role="fieldcontain">
            <a href="comment-box.html" data-prefetch><img src="fake-textfield.jpg"/>
            </a>
        </div>
    </div>




  • 当您点击该链接时,该网页会按照您第二次访问该网页的方式工作,从而启用焦点和键盘。

  • 这篇关于输入焦点在jQuery移动,但键盘不出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆