angularjs - keyboard navigation in the Bootstrap dropdown-menu -
as know using boostrap drop-down components not able select element pressing keyboard letter. using following code use directive
myapp.directive('keyletterpressed', function ($timeout) { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { var target = $(event.target); $(target).trigger('focus'); }); }; });
but not complete, not working, can tell me how go element have same letter of list ? have put directive in ul element ? because using on li
<li ng-repeat="v in values" keyletterpressed>{{v.name}}</li>
another answer this, adding directive ul element
app.directive('booststrapdropdown', function () { return { restrict: 'a', link: function (scope, element, attr) { console.log('linked'); element.parent().bind('keypress', function (e) { children = element.children(); children.removeclass("active"); (var = 0; < children.length; i++) { var letter = string.fromcharcode(e.which); var charat = children[i].textcontent.replace(/\s+/, '').charat(0); if (charat === letter) { children[i].classname += " active"; element[0].scrolltop = children[i].offsettop; } } }); } }; }); <div class="btn-group" dropdown> <button type="button" class="btn btn-primary dropdown-toggle" dropdown-toggle> button dropdown <span class="caret"></span> </button> <ul booststrap-dropdown class="dropdown-menu scrollable-menu" role="menu" > <li ng-repeat="v in values"> <a href="#">{{v.name}}</a> </li> </ul> </div>
Comments
Post a Comment