I have an directive in angular JS, that generates an Bootstrap dropdown-button. All works fine.
Also I would like to open and close the dropdown by pressing an key on the keyboard. That also works fine! But I can only close the dropdown-menu with pressing the keyboard-key not with mouse. And i can't use the arrows to navigate in the dropdown-menu - do you have any ideas?
PS: sorry for my real bad english...
app.directive('xnBtn', ['$http', function($http) {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: true,
link : function (scope, e, a) {
$(document).keydown(function(evt){
if (evt.ctrlKey && evt.altKey && evt.keyCode == 78) { // N-Key
$('.dropdown-menu', e).toggle('toggle'); //.focus();
return false;
}
});
scope._cn3j2_bcList = {};
$http({method: 'POST', url: '/system/xn', data: $.param(sURe)}).
success(function(data) {
scope._cn3j2_bcList = data; // fills the list with an array
});
},
templateUrl: '/assets/directives/tmp/xnbtn.html'
}
}]);
if(mouse is clicked) {$('.dropdown-menu', e).toggle('toggle');}
– ewizard Jun 23 at 15:09