问题显然是弹出框做了它应该做的事情。当您将弹出框附加到<tr>' 时,让弹出框响应悬停 - 并且弹出框挂在<tr>' 底部下方 - 您将永远无法访问弹出框的内容。
触发器:悬停可以很容易地被触发器模仿:手动像这样
$('table').on('mouseenter', 'tr', function() {
$(this).popover('show');
});
$('table').on('mouseleave', 'tr', function() {
$(this).popover('hide');
});
设置 trigger:manual 使我们能够操纵弹出行为。mouseenter下面的解决方案为/ -events增加了一点延迟mouseleave,然后检查鼠标是否在弹出框内(通过将事件附加到弹出框本身)。如果鼠标在弹出框内,则不会显示新的弹出框,并且不会隐藏活动的弹出框,即使mouseenter在另一个中存在 -event 也是如此<tr>。分叉的jsfiddle:http: //jsfiddle.net/xZxkq/
var insidePopover=false;
function attachEvents(tr) {
$('.popover').on('mouseenter', function() {
insidePopover=true;
});
$('.popover').on('mouseleave', function() {
insidePopover=false;
$(tr).popover('hide');
});
}
$('table').on('mouseenter', 'tr', function() {
var tr=$(this);
setTimeout(function() {
if (!insidePopover) {
$(tr).popover('show');
attachEvents(tr);
}
}, 200);
});
$('table').on('mouseleave', 'tr', function() {
var tr=$(this);
setTimeout(function() {
if (!insidePopover) $(tr).popover('hide');
}, 200);
});