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

135
Views
Bootstrap popover content callback called twice on every second click

I'm trying to create a feature that will display the popover with manual click event. My goal is to populate the popover and display newest data through ajax call after every click.

The problem I'm facing is described on the title.

For example:

1st click -> call once
2nd click -> call twice
3rd click -> call once
4th click -> call twice
... 

The code look like this:

$popoverButton.popover({
    container: 'body',
    template: `<div></div>`,
    title: 'title',
    content: function () {
        console.log('*');  // this called twice on every second click
        let id = $(this).attr('data-id');
        return initPopover(id);
    },
    html: true,
    trigger: 'manual',
});
function initPopover(id) {
    let $popover = $('<div class="popover-body"></div>');
    $popover.attr({'id': 'popover-body-' + id});
    let $spinner = $(`<div class="spinner"><span class="spinner-border"></span></div>`);
    $popover.append($spinner);
    let $sellers = $('<div class="sellers"></div>');
    $popover.append($sellers);
    return $popover;
}

To open the popover, I declared the click event with these functions:

$popoverButton.on('click', function () {
        closePopover();
        openPopover($(this));
});
closePopover() {
    $popoverButton.popover('hide');  
}
openPopover($targetButton) {
    // hide all opened popovers
    $('.popover').popover('hide');  
    $targetButton.popover('show');
    getSellersAndAppendData();
}

I'm not sure why this happened. Please help.

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