Search code examples
javascriptangularjstooltip

Show/Hide tooltip on button click


How to stop/block tooltip from hiding on mouseout/mouseleave in angular-tooltips?

I need to show and hide the tooltip on button click instead.


Solution

  •    app.directive('tooltip', function(){
            return {
                restrict: 'A',
                link: function(scope, element, attrs){
                    $(element).hover(function(){ // or you can use click instaed of hover
                        // on mouseenter
                        $(element).tooltip('show');
                    }, function(){
                        // on mouseleave
                        $(element).tooltip('show'); //or you can remove this one
                    });
                }
            };
        });