【发布时间】:2011-09-28 14:36:20
【问题描述】:
这工作正常:
$('#panel_derecho a.tooltip').each(function(){
$(this).qtip({
content: { url: '/includes/qtip.php?'+$(this).attr('rel')+' #'+$(this).attr('div'), text:'<center><img src="/images/loader.gif" alt="loading..." /></center>' },
show: { delay: 700, solo: true,effect: { length: 500 }},
hide: { fixed: true, delay: 200 },
position: {
corner: {
target: 'topLeft',
tooltip: 'middleRight'
}
},
style: {
name: 'light',
width: 700,
padding: 0,border: {
width: 4,
radius: 3,
color: '#5588CC'
}
}
});
});
但有时用户在向下滚动页面时悬停,并且许多对 qtip 的调用不会显示在调用的位置,因此认为添加超时是最好的选择(不是吗?)
所以我尝试将 delayTip var 设置为等待时间(悬停时)并在鼠标移出时清除它:
$('#panel_derecho a.tooltip').each(function(){
var delayTip;
$(this).bind('mouseover',function(){
delayTip = setTimeout(function () {
$(this).qtip({
content: { url: '/includes/qtip.php?'+$(this).attr('rel')+' #'+$(this).attr('div'), text:'<center><img src="/images/loader.gif" alt="loading..." /></center>' },
show: { delay: 700, solo: true,effect: { length: 500 }},
hide: { fixed: true, delay: 200 },
position: {
corner: {
target: 'topLeft',
tooltip: 'middleRight'
}
},
style: {
name: 'light',
width: 700,
padding: 0,border: {
width: 4,
radius: 3,
color: '#5588CC'
}
}
});
}, 500);
};
$(this).bind('mouseout',function(){ clearTimeout(delayTip); });
});
提示是没有显示工具提示,并且在 firebug 中没有错误跳转,
我错过了什么?
【问题讨论】:
-
我会在其中添加一些调试代码,以确保您知道 mouseover 和 mouseout 事件处理程序正在触发。
console.log('mouseover fired')等
标签: javascript jquery timeout settimeout qtip