Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

95
Visualizações
Prevent tooltip from showing using onTrigger

Situation: I have a div with a Tippy attached to it, and inside the DIV there are highlighted spans with their own tooltips. They all use click as triggers.

Ideal behavior: When I click on a highlight, only the highlight Tippy should show.

Current behavior: Both tooltips show at the same time.

I can catch the click with onTrigger, using event.target. However, return false or instance.hide() do not prevent it from showing. Is there a way I can do that with onTrigger?

tippy(divEl, {
    content: 'Tooltip!',
    allowHTML: true,
    onTrigger(instance, event) {
        if (event.target.className == 'highlight') {
            console.log('It should hide the tooltip!');
            instance.hide();
            return false;
        }
    },
    arrow: true,
    interactive: true,
    trigger: 'click',
    theme: 'light-border',
    zIndex: 9999
  });
}

I got it working with the following trick, but it wouldn't work if I had other DIVs inside the main DIV:

tippy(divEl, { ...,

  onShow(instance) {
    if (divEl.lastChild.nodeName == "DIV") {return false}
  },
});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda