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

202
Visualizações
Prevent Bootstrap popover from appearing before it gets hidden by .hide()

I'm trying to make it so that a popover does/doesn't appear based on a conditional.

  <form class="submit-form" action="{% url 'search' %}" method="post">
                                {% csrf_token %}
                                <input type="submit" class="show-more-button pop" id="mybtn" style="margin-left: 5px" name="mybtn"
                                       value="Search" data-bs-toggle="popover"
                                       data-bs-placement="right" data-bs-trigger="focus"
                                       data-bs-content="Please select one or more ingredient">
                            </form>

$(document).on('click', '#mybtn', function (){
    var $btn = $('#mybtn')[0]
    var $pop = bootstrap.Popover.getInstance($btn)
    if ($(lst).length > 0) {
        $pop.hide()       
    }

However, on clicking the button the popover comes up briefly before being hidden. Is there any way I can basically prevent the popover from appearing in the first place if the conditional is met or at least make it so that it doesn't flash before it's hidden?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The popover is being shown by Bootstrap due to the data-bs-toggle="popover" attribute. After that gets run, then your hiding code gets run. Hence the brief appearance.

Bootstrap has a "show.bs.popover" event. My guess is if you attach a listener for that event, then preventDefault on the event, that'll stop the popover from showing.

Alternatively, rather than relying on Bootstrap to automatically trigger the popover, you could do it manually - and only manually trigger the popover if the conditions succeed.

about 4 years ago · Juan Pablo Isaza Relatório
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