UI select angular 禁用搜索在移动设备上弹出键盘
UI select angular with disabled search pops out keyboard on mobile devices
我在 bootstrap 上为 angular 使用 select 2 主题。
默认情况下,它有一个内置的 'search' 可以过滤选项行。
我不想要那一行,所以我在网上搜索解决方案。
常见的解决方案是使用 ng-disabled,它适用于某些浏览器,但在手机上仍然会弹出键盘。
我使用了这个 plunker 中描述的 'return false' 方法:
http://plnkr.co/edit/jE0qBpewzvHG5oamB7vQ?p=preview&s=TIKKc2Zmyq5lcvXI
然而当我在手机上打开它时(chrome 上的 lg g2)我有两个问题:
键盘弹出
我会打字(奇怪的是我不会打英文但我会打希伯来语)
pluker 上描述的代码:
<ui-select multiple ng-model="multipleDemo.colors" onkeypress="return false;" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">
<span ng-if="!disabled">{{$item}}</span>
<span ng-if="disabled">
<a class="glyphicon glyphicon-remove" ng-click="$select.removeChoice($index)" tabindex="-1"></a>
{{$item}}
</span>
</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
我不想弹出键盘,也不想让用户打字。
这在本机 android 浏览器上无法重现,只能在 Chrome.
上重现
最终我结合了几种解决方案 - 最有帮助的是 - html-mobile-forcing-the-soft-keyboard-to-hide
现在我的 select 看起来像这样:
<ui-select
ng-model="multipleDemo.colors"
onkeypress="return false;"
theme="select2"
ng-disabled="disabled"
onfocus="blur();" >
.
.
</ui-select>
我在 bootstrap 上为 angular 使用 select 2 主题。
默认情况下,它有一个内置的 'search' 可以过滤选项行。 我不想要那一行,所以我在网上搜索解决方案。 常见的解决方案是使用 ng-disabled,它适用于某些浏览器,但在手机上仍然会弹出键盘。
我使用了这个 plunker 中描述的 'return false' 方法: http://plnkr.co/edit/jE0qBpewzvHG5oamB7vQ?p=preview&s=TIKKc2Zmyq5lcvXI
然而当我在手机上打开它时(chrome 上的 lg g2)我有两个问题:
键盘弹出
我会打字(奇怪的是我不会打英文但我会打希伯来语)
pluker 上描述的代码:
<ui-select multiple ng-model="multipleDemo.colors" onkeypress="return false;" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">
<span ng-if="!disabled">{{$item}}</span>
<span ng-if="disabled">
<a class="glyphicon glyphicon-remove" ng-click="$select.removeChoice($index)" tabindex="-1"></a>
{{$item}}
</span>
</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
我不想弹出键盘,也不想让用户打字。
这在本机 android 浏览器上无法重现,只能在 Chrome.
上重现最终我结合了几种解决方案 - 最有帮助的是 - html-mobile-forcing-the-soft-keyboard-to-hide
现在我的 select 看起来像这样:
<ui-select
ng-model="multipleDemo.colors"
onkeypress="return false;"
theme="select2"
ng-disabled="disabled"
onfocus="blur();" >
.
.
</ui-select>