2017-02-01 1 views
2

Я использую tooltipster для создания некоторых вызовов. У меня есть несколько щелчков, некоторые - на паре.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 все остальные должны закрыть перед выбранным открытым. ФункцияBefore работает нормально с триггером: нажмите. Но если я назову тот, у кого есть триггер, все остальные не закрываются.

спасибо за помощь

ответ

2

Похоже, вам нужно вызвать метод $.tooltipster.instances() в функции functionBefore для ссылки на последние случаи:

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

спасибо, отлично! –

Смежные вопросы