javascript - create a hover-tooltip which can be clicked in angularjs - Stack Overflow

I am trying to create a hover-tooltip using Bootstrap UI. The tooltip should be visible when mouse is h

I am trying to create a hover-tooltip using Bootstrap UI. The tooltip should be visible when mouse is hovered on the button, the tooltip has a link which should be clickable. But the default popover and tooltip provided by Bootstrap UI, disappear when mouse es out of it. I have searched a lot online, but couldn't find a solution. Some sites have given a solution using jQuery, but my requirement is in AngularJS. Many sites cite that we have to use $tooltipProvider, could you please tell me how to write a customEvent for 'mouseenter' and 'mouseleave' inside the controller.

I am trying to create a hover-tooltip using Bootstrap UI. The tooltip should be visible when mouse is hovered on the button, the tooltip has a link which should be clickable. But the default popover and tooltip provided by Bootstrap UI, disappear when mouse es out of it. I have searched a lot online, but couldn't find a solution. Some sites have given a solution using jQuery, but my requirement is in AngularJS. Many sites cite that we have to use $tooltipProvider, could you please tell me how to write a customEvent for 'mouseenter' and 'mouseleave' inside the controller.

Share Improve this question asked Jun 3, 2015 at 10:25 akashrajknakashrajkn 2,3152 gold badges24 silver badges47 bronze badges 2
  • stackoverflow./questions/13015432/… – nikhil mehta Commented Jun 3, 2015 at 10:32
  • 1 That one doesn't use the angular tooltip – devqon Commented Jun 3, 2015 at 10:33
Add a ment  | 

3 Answers 3

Reset to default 1

check this link,

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

It has been achieved using jQuery, write a directive in AngularJS. You can integrate jQuery plugin in angularJS app, look at this site

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

Are you looking for popover tooltip which is being stable and hide once it is accessed...Please see below working fiddle:

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>

I made a sticky dropdown extension for dropdown. Here's my code:

'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);
                }
            });
        }
    };
} ]);

and to use it:

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744890406a4599376.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信