angularjs – 如何在选择选项后从ui-select中删除焦点
发布时间:2020-12-17 07:09:40 所属栏目:安全 来源:网络整理
导读:一旦用户使用鼠标单击选择了一个选项并进入开始搜索,我需要从ui-select输入中删除焦点.现在发生的事情是焦点仍然存在于select中,因此下拉列表在单击enter时打开. ui-select id= "country" ng-model="ctry" name= "country" theme="bootstrap" ui-select-matc
一旦用户使用鼠标单击选择了一个选项并进入开始搜索,我需要从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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |