Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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'
    }
}]);
share|improve this question
    
ive never tried making the arrows work with a js menu - but i'm guessing it would take some hardcoding with actually telling the arrows what they have to do and where. –  ewizard Jun 23 at 15:08
    
to make it work with the mouse to escape you might need something like if(mouse is clicked) {$('.dropdown-menu', e).toggle('toggle');} –  ewizard Jun 23 at 15:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.