使用setTimeout和clearTimeout延迟qTip呼叫
delay qTip call using setTimeout and clearTimeout
运行正常:
$('#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中没有错误跳转,
我错过了什么?
当超时触发时,this
关键字引用全局对象(很可能是window
),尝试这样做:
$('#panel_derecho a.tooltip').each(function(){
var delayTip = 0;
var self = $(this);
self.bind('mouseover',function(){
if (delayTip === 0) delayTip = setTimeout(function () {
self.qtip({
content: { url: '/includes/qtip.php?'+self.attr('rel')+' #'+self.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'
}
}
});
delayTip = 0;
}, 500);
};
self.bind('mouseout',function(){ clearTimeout(delayTip); delayTip = 0; });
});
相关文章:
- NodeJS Promise从未达到第三位'然后()'呼叫
- 谷歌地图v3:当函数'失败'呼叫
- 客户端的服务呼叫
- Keydown/Keyup被呼叫7次
- 来自网络的Android呼叫阻止
- 巴贝尔/因果报应/柴给出类型错误:'呼叫者''被叫',和'自变量'在严格模
- JQuery 呼叫弹出窗口
- 无法使 qtip 集正常工作
- 通过呼叫.aspx.vb从.html页面发送电子邮件
- Phonegap:无法通过 HTTP 呼叫远程主机
- 使用 AJAX 的呼叫控制器
- 用于在组合文件中查找 AMD 定义呼叫的正则表达式
- Extjs 3.4 中属性网格行值的工具提示 /Qtip(鼠标悬停)
- 名为“;清除“;没有被呼叫.尝试呼叫“;clear()”;使用内联js
- ANT任务呼叫Karma/Jasmine
- 按键点击时的呼叫按键事件
- 如何在两个连续的角度服务呼叫期间中止/取消第一个呼叫的承诺
- 未捕获的类型错误:无法读取属性'呼叫'在webpack重新生成CommonsChunkPlugin后,共
- Azure移动服务;插入到另一个表&呼叫'插入'剧本
- 使用setTimeout和clearTimeout延迟qTip呼叫