Last active
December 16, 2015 12:38
-
-
Save manute/5435554 to your computer and use it in GitHub Desktop.
Control hover twitter bootstrap popover.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var $popoverInbox = $('#example').popover({ | |
title: 'Test', | |
placement: 'bottom', | |
trigger:'manual', | |
template: '<div class="popover-all"><div class="popover-arrow"></div><div class="popover-inner"><h3 class="popover-title">Example</h3><div class="popover-content"></div></div></div>' | |
}); | |
var timerPopover, popover_parent; | |
function hidePopover(elem) { | |
$(elem).popover('hide'); | |
} | |
$('#example').hover( | |
function() { | |
var self = this; | |
clearTimeout(timerPopover); | |
$('.popover-all').hide(); //Hide any open popovers on other elements. | |
popover_parent = self; | |
$(self).popover('show'); | |
}, | |
function() { | |
var self = this; | |
timerPopover = setTimeout(function(){hidePopover(self);},300); | |
} | |
); | |
$(document).on({ | |
mouseenter: function() { | |
clearTimeout(timerPopover); | |
}, | |
mouseleave: function() { | |
var self = this; | |
timerPopover = setTimeout(function(){hidePopover(popover_parent);},300); | |
} | |
}, '.popover-all'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment