一旦用户使用鼠标单击选择了一个选项并进入开始搜索,我需要从ui-select输入中删除焦点.现在发生的事情是焦点仍然存在于select中,因此下拉列表在单击enter时打开.
<ui-select id= "country" ng-model="ctry" name= "country" theme="bootstrap"> <ui-select-match >{{text || $select.selected.id}}</ui-select-match> <ui-select-choices repeat="countryL in countryLookup | filter: $select.search"> <div ng-bind-html="countryL.id | highlight: $select.search"></div> <small ng-bind-html="countryL.name | highlight: $select.search"></small> </ui-select-choices>
解决方法
将on-select =“onSelected($item)”添加到你的ui-select和控制器中:
$scope.onSelected = function (selectedItem) { setTimeout(function(){ $(':focus').blur(); }) }
或在控制器中使用$timeout