【发布时间】:2015-01-04 08:38:58
【问题描述】:
当在移动设备上使用 select2 时,我遇到了问题。 单击时,将显示虚拟键盘。我尝试使用类似的东西
$('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;
}
});
没有成功。即使我尝试简单地使用
shouldFocusInput: false
搜索文本不断获得焦点。
【问题讨论】:
-
如果您不允许搜索,为什么还要使用 select2?
-
我确实想允许搜索,我只需要取消点击时的自动对焦。
-
这就是 {shouldFocusInput: false} 的意义所在……我不知道为什么它不起作用。我也尝试更新库,但没有。
标签: jquery jquery-select2