我无法找到这个问题的正确答案。 如何将工具提示设置为每位访问者仅显示一次? 我在一些论坛上找到的唯一答案就是添加这个
$('.selector').qtip({
content: 'blah',
api: {
onHide: function(event, api) {
api.destroy();
}
}
});
但我知道这不推荐,但无论如何都不行。
这就是我的代码的样子:
$('#win').qtip({
content: {
text: 'Some text',
title: {
text: 'Some other text',
button: 'Close' // Close button
}
},
show: {
event: false,
when: true,
ready: true
},
position: {
my: 'top right',
at: 'bottom left',
target: $('#win')
},
hide: false
})
答案 0 :(得分:0)
您可以随时使用方法disable(true/false)
启用和停用工具提示。
如果您只想展示一次:
$('#win').on('mouseleave', function(){
var $item = $(this);
setTimeout(function(){
$item.qtip('api').disable(true);
},0);
});
稍后您可以启用工具提示:$('#win').qtip('api').disable(false);
使用jquery-cookie.js的解决方案如下所示:
var $win = $('#win').qtip();
if($.cookie('win')) $win.qtip('api').disable(true);
$win.on('mouseleave', function() {
$.cookie('win', 'true');
var $item = $(this);
setTimeout(function() {
$item.qtip('api').disable(true);
}, 0);
});