问题描述
当我在angularjs中为自定义select2指令设置tabindex时,按Tab键后它会获得焦点,但是它的列表无法使用alt +下箭头键打开。 我试图修复2天,但没有得到结果。
select2版本4.0.13
<kama-select tabindex="1" obj="students"></kama-select>
<script>
angular.module('kama',[]).controller('mycontroller',['$scope',function ($scope) {
$scope.students = {
items: [
{ 'id': 1,'name': 'moslem' },{ 'id': 2,'name': 'reza' },{ 'id': 3,'name': 'mohammad' },{ 'id': 4,'name': 'ali' },{ 'id': 5,'name': 'hamid' },]
};
}])
.directive('kamaSelect',function () {
var directive = {
link: link,restrict: 'E',template: `
<select tabindex="1" style="width:10%" class="kama-select" ng-options="item.name for item in obj.items track by item.id"
ng-model="selected">
<option value="" selected="selected"></option>
</select>
`,scope: {
obj: '=',},}
return directive;
function link(scope,element,attr) {
$(element.find(".kama-select")[0]).select2({
allowClear: true,placeholder: "select..",data: scope.obj
});
}
});
// ***************** manage tab key **************************************************
//some javascript code for manage tab key between element
//**************************************************************************************
</script>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)