在jquery mobile中输入焦点,但键盘没有出现 [英] input focus in jquery mobile, but keyboard doesn't appear

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

问题描述

我正在使用 jquery、jquery mobile 和 phonegap.我想用 input 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();在我第二次访问该页面后工作.因此,我强制 jquery mobile 对我的评论框页面进行数据预取.

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 初始化代码(如果没有数据预取",它将无法工作):

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

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

在列表页面上有一个小文本框的假图像,它重定向到comment-box.html,它只是一个带有发布和取消按钮的大测试区域.

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 mobile中输入焦点,但键盘没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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