Create a tooltip that can be clicked in the corner

I am trying to create a tooltip using Bootstrap UI. The tooltip should be visible when the mouse pointer is over the button; there is a link in the tooltip that needs to be clicked. But by default, the popover and tooltip provided by the Bootstrap user interface disappear when the mouse exits from it. I searched a lot on the Internet, but could not find a solution. Some sites gave a solution using jQuery, but my requirement is in AngularJS. Many sites cite the fact that we should use $ tooltipProvider, could you please tell me how to write customEvent for "mouseenter" and "mouseleave" inside the controller.

+4
source share
3 answers

check this link

http://fiddle.jshell.net/WojtekKruszewski/Zf3m7/22/light/

This was achieved using jQuery, write a directive in AngularJS. You can integrate jQuery plugin into angularJS application, see this site

https://amitgharat.wordpress.com/2013/02/03/an-approach-to-use-jquery-plugins-with-angularjs/

+1
source

You are looking for a tooltip that is stable and hidden after its access ... Please see the working script below:

Fiddle

<i class="fa fa-info-circle infoIcon" data-toggle="popover" data-content='Lorem Ipsum<br/><a href="#"><span class="learnMore">Learn More</span></a>'></i>

JS:

<i class="fa fa-info-circle infoIcon" data-toggle="popover" data-content='Lorem Ipsum<br/><a href="#"><span class="learnMore">Learn More</span></a>'></i>
+1
source

. :

'use strict';

angular.module('ui.bootstrap.stickyDropdownToggle', []).directive('stickyDropdownToggle', ['$document', '$location', function ($document, $location) {
    var openElement = null,
      closeMenu = angular.noop;
    return {
        restrict: 'CA',
        link: function (scope, element, attrs) {
            scope.$watch('$location.path', function () { closeMenu(); });
            element.parent().bind("click", function (event) { if (event) { event.stopPropagation(); } });
            element.bind('click', function (event) {

                var elementWasOpen = (element === openElement);

                event.preventDefault();
                event.stopPropagation();

                if (!!openElement) {
                    closeMenu();
                }

                if (!elementWasOpen && !element.hasClass('disabled') && !element.prop('disabled')) {
                    element.parent().addClass('open');
                    openElement = element;
                    closeMenu = function (event) {
                        if (event) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                        $document.unbind('click', closeMenu);
                        element.parent().removeClass('open');
                        closeMenu = angular.noop;
                        openElement = null;
                    };
                    $document.bind('click', closeMenu);
                }
            });
        }
    };
} ]);

:

<button type="button" class="btn sticky-dropdown-toggle" ng-click="focusOnParticularElementInsideThePopup()"
                                        style="font-size: 1em">
                                    <span class="glyphicon glyphicon glyphicon-tags"></span>
                                </button>
0

All Articles