行动装置上的select2键盘问题 [英] select2 keyboard issue on mobile

查看:66
本文介绍了行动装置上的select2键盘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在移动设备上使用select2时,我遇到了问题. 单击后,将显示虚拟键盘.我尝试使用类似的东西

I have an issue with select2, when it is being used on mobile devices. On click, the virtual keyboard is shown. I tried using something like

$('select').select2({
  shouldFocusInput: function (instance) {
        // Attempt to detect touch devices
        var supportsTouchEvents = (('ontouchstart' in window) ||
                                   (navigator.msMaxTouchPoints > 0));

        // Only devices which support touch events should be special cased
        if (!supportsTouchEvents) {
            return true;
        }

        // Never focus the input if search is disabled
        if (instance.opts.minimumResultsForSearch < 0) {
            return false;
        }

        return true;
    }
});

没有成功.即使我尝试简单地使用

with no success. Even if I try to simply use

shouldFocusInput: false

搜索文字不断集中注意力.

the search text keeps getting focused.

推荐答案

您尝试过

minimumResultsForSearch = -1

问题发布: https://github.com/ivaynberg/select2/issues/1541

这篇关于行动装置上的select2键盘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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