Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!