Twitter bootstrap 3 如果将元素悬停更长时间,则显示popover
使用引导popover将隐藏div的内容显示为popover内容 在主元素至少一秒钟没有悬停之前,如何实现不显示popoverTwitter bootstrap 3 如果将元素悬停更长时间,则显示popover,twitter-bootstrap-3,bootstrap-popover,Twitter Bootstrap 3,Bootstrap Popover,使用引导popover将隐藏div的内容显示为popover内容 在主元素至少一秒钟没有悬停之前,如何实现不显示popover $(function () { $("[data-toggle=popover]").popover({ trigger: "manual", html: true, content: function () { var content = $(this).attr("data-popover-content");
$(function () {
$("[data-toggle=popover]").popover({
trigger: "manual",
html: true,
content: function () {
var content = $(this).attr("data-popover-content");
return $(content).children(".popover-body").html();
},
title: function () {
var title = $(this).attr("data-popover-content");
return $(title).children(".popover-heading").html();
}
})
.on("mouseenter", function () {
var _this = this;
$(_this).popover("show");
$(".popover").on("mouseleave", function () {
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 300);
});
})
.on("mouseleave", function () {
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 300);
});});
我有一个包含很多图标的表格。每个图标都有一些大数据,因此被移动到可滚动的弹出窗口。我想显示popowers,但它太大了,以至于你在页面上移动鼠标,它们都会亮起来。这就是为什么我需要在它们出现之前延迟。鼠标离开后的延迟是,当我想输入并滚动其内容时,弹出窗口不会关闭。
我更改代码,单击打开它们,直到得到另一个解决方案。
Fiddle:使用一个标志变量,并用一些
setTimeout
s检查/设置它
var timerReady = false
var showPopup;
$("[data-toggle=popover]").popover({
trigger: "manual",
html: true,
content: function() {
var content = $(this).attr("data-popover-content");
return $(content).children(".popover-body").html();
},
title: function() {
var title = $(this).attr("data-popover-content");
return $(title).children(".popover-heading").html();
}
})
.on("mouseenter", function() {
var _this = this;
timerReady = true
showPopup = setTimeout(function(){
if(timerReady){
$(_this).popover("show");
}
}, 1000)
})
.on("mouseleave", function() {
clearTimeout(showPopup)
timerReady = false
var _this = this;
setTimeout(function() {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 300);
});
使用一个标志变量并用一些
setTimeout
s检查/设置它
var timerReady = false
var showPopup;
$("[data-toggle=popover]").popover({
trigger: "manual",
html: true,
content: function() {
var content = $(this).attr("data-popover-content");
return $(content).children(".popover-body").html();
},
title: function() {
var title = $(this).attr("data-popover-content");
return $(title).children(".popover-heading").html();
}
})
.on("mouseenter", function() {
var _this = this;
timerReady = true
showPopup = setTimeout(function(){
if(timerReady){
$(_this).popover("show");
}
}, 1000)
})
.on("mouseleave", function() {
clearTimeout(showPopup)
timerReady = false
var _this = this;
setTimeout(function() {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 300);
});
你能看看我做的这个小提琴吗?我不知道如何解决这个延误。我是个笨蛋。是的,这比我最初想象的要复杂一些。我已经编辑了我的答案——与flag变量的概念类似,只是需要稍微更改一下范围。请接受它,如果你发现这可以完成工作。这是有效的!谢谢你,好心的先生。我已经更新了提琴,以防其他人发现这有帮助:说话有点太早了。你看到当你有多个popovered项目,你移动到第一个到另一个?它显示了两个弹出框,尽管您仅将第二个弹出框悬停了一秒钟以上:-/哦,是的,我明白您的意思。让我再想一想——我不会抛弃你,但我鼓励你看看你是否能扩展我提供的解决方案,看看你是否能解决其他问题。你能看看我为测试这个而做的小提琴吗?我不知道如何解决这个延误。我是个笨蛋。是的,这比我最初想象的要复杂一些。我已经编辑了我的答案——与flag变量的概念类似,只是需要稍微更改一下范围。请接受它,如果你发现这可以完成工作。这是有效的!谢谢你,好心的先生。我已经更新了提琴,以防其他人发现这有帮助:说话有点太早了。你看到当你有多个popovered项目,你移动到第一个到另一个?它显示了两个弹出框,尽管您仅将第二个弹出框悬停了一秒钟以上:-/哦,是的,我明白您的意思。让我再仔细考虑一下——我不会抛弃你,但我鼓励你看看你是否可以扩展我提供的解决方案,看看你是否可以解决其他问题。