[英]Tooltipster close all before opening a new one, click/hover combination
我正在使用tooltipster來構建一些標注。 我點擊了一些,有些是懸停。
JS:
var instances = $.tooltipster.instances();
$('.mgu-click').tooltipster({
functionBefore: function(instance, helper) {
$.each(instances, function(i, instance) {
instance.close();
});
},
contentCloning: true,
trigger: 'click',
'maxWidth': 280,
'minHeight': 280,
animation: 'grow',
interactive: true,
arrow: false,
distance: -10,
contentAsHTML: true,
theme: 'tooltipster-shadow'
});
$('.mgu-hover').tooltipster({
functionBefore: function(instance, helper) {
$.each(instances, function(i, instance) {
instance.close();
});
},
contentCloning: true,
trigger: (browser.hasTouchEvents()) ? 'click' : 'hover',
'maxWidth': 280,
'minHeight': 280,
animation: 'grow',
interactive: true,
arrow: false,
distance: -10,
contentAsHTML: true,
theme: 'tooltipster-shadow'
});
如果單擊或移動到tooltipster-btn,則所有其他應在所選打開之前關閉。 函數使用觸發器正常工作:單擊。 但如果我用觸發器懸停調用那個,所有其他都不要關閉。
感謝幫助
看起來你需要調用functionBefore
函數中的$.tooltipster.instances()
方法來引用最新的實例:
functionBefore: function(instance, helper){
$.each($.tooltipster.instances(), function(i, instance){
instance.close();
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.