How can I hold Twitter Bootstrap Popover open until my mouse moves into it?

前端 未结 16 1406
野性不改
野性不改 2020-12-04 05:55

I have a link that uses the Twitter Bootstrap Popover version 1.3.0 to show some information. This information includes a link, but every-time I move my mouse from the link

16条回答
  •  清歌不尽
    2020-12-04 06:40

    This is a little hacky, but building off of marchello's example, I did this (no need for template):

    $(".trigger-link").popover({
      trigger: "manual",
    }).on("click", function(e) {
      e.preventDefault();
    }).on("mouseenter", function() {
      var _this = this;
      $(this).popover("show");
      $(this).siblings(".popover").on("mouseleave", function() {
        $(_this).popover('hide');
      });
    }).on("mouseleave", function() {
      var _this = this;
      setTimeout(function() {
        if (!$(".popover:hover").length) {
          $(_this).popover("hide")
        }
      }, 100);
    });
    

    The setTimeout helps ensure that there's time to travel from the trigger link to the popover.

提交回复
热议问题