【问题标题】:Open IOS keyboard on Focus of element在元素焦点上打开 IOS 键盘
【发布时间】:2014-11-11 21:40:13
【问题描述】:

当用户点击链接时,我正在使用指令触发输入字段的焦点。除了 IOS,它在任何地方都可以正常工作。它没有在焦点上打开 ios 设备(iphone/ipad)上的键盘。它在输入周围添加了蓝色边框,表明它正在聚焦。如何在焦点上打开 ios 设备中的键盘?

HTML

 <a data-mya-triggerfocus="something" >Something</a>
 <input name="something" id="something" />

JS

   angular.module('app').directive('myaTriggerfocus', function ($timeout) {
    return {
        link: function (scope, element, attrs) {
            element.bind('click', function () {
                $timeout(function () {
                    var otherElement = document.querySelector('#' + attrs.myaTriggerfocus);  
                        otherElement.focus();      
                });
            });
        }
    };
});

【问题讨论】:

    标签: jquery ios angularjs angularjs-directive


    【解决方案1】:

    放置“类型”属性有帮助吗?

    <a data-mya-triggerfocus="something" >Something</a>
    <input name="something" **type="text"** id="something" />
    

    要显示数字键盘,您可以尝试:

    <input type="text" pattern="[0-9]*">
    

    我想回忆一下 Apple 的文档建议 - 将模式属性的值设置为“[0-9]*”或“d*”以打开数字小键盘。不确定这里是否相关。只是说..

    【讨论】:

    • 没有。它没有帮助。焦点将边框变为蓝色,但实际上并未将光标放入并打开键盘。有什么建议如何触发“TOUCH”事件?
    【解决方案2】:

    尝试添加:

    <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
    

    在您的应用程序的 config.xml 文件中。

    (那是根据ios的定义)

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 2017-03-14
      • 2011-05-25
      • 2019-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多