简体   繁体   English

Tooltipster在打开新的之前关闭所有,单击/悬停组合

[英]Tooltipster close all before opening a new one, click/hover combination

I'm using tooltipster to build some call-outs. 我正在使用tooltipster来构建一些标注。 I've some on click, some on hover. 我点击了一些,有些是悬停。

JS: 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'
});

If you click or move to a tooltipster-btn all other should close before the selected open. 如果单击或移动到tooltipster-btn,则所有其他应在所选打开之前关闭。 The functionBefore work fine with the trigger: click. 函数使用触发器正常工作:单击。 But if i call the one with trigger hover, all other dont close. 但如果我用触发器悬停调用那个,所有其他都不要关闭。

thanks for help 感谢帮助

It looks like you need to call the $.tooltipster.instances() method within the functionBefore function for a reference to the latest instances: 看起来你需要调用functionBefore函数中的$.tooltipster.instances()方法来引用最新的实例:

functionBefore: function(instance, helper){
  $.each($.tooltipster.instances(), function(i, instance){
    instance.close();
  });
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM