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

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

问题描述

我正在使用 jquery、jquery mobile 和 phonegap.我想用 input type="text" 在这个页面上显示键盘.

 
<header data-role="header"><h1>jQuery Mobile</h1></标题><div data-role="content" class="content"><input type="text" placeholder="입력하세요"/>

</节>

我的脚本是

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

文本框已聚焦但键盘不显示,并且在单击 input type="text" 时启动.如何强制在 javascript 中或使用 phonegap 插件启动键盘?

解决方案

以前的解决方案都不适合我.但是,我注意到 $('textarea').focus().select();我第二次访问该页面后工作.因此,我强制 jquery mobile 对我的评论框页面进行数据预取.

这是我的通用 JQM 初始化代码(如果没有数据预取",它就无法工作):

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

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

 

<div data-role="fieldcontain"><a href="comment-box.html" 数据预取><img src="fake-textfield.jpg"/></a>

  • 数据预取是与众不同的地方.当您点击该链接时,该页面的行为将与您第二次访问时一样,启用焦点并调出键盘.

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>

and my script is

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

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?

解决方案

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.

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

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

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

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆