Skip to content

Bootstrap 5 content function only gets called once #41255

@SoftCircuits

Description

@SoftCircuits

I have the following JavaScript/jQuery code that creates and initializes a number of Bootstrap popovers.

I need the text to be updated each time it is shown, so I thought being able to set content to a function would be perfect. However, this function only gets called once per popover. So instead of updating each time it is displayed, it just keeps showing its initial value.

// Initialize example conversion popovers
$('img.example-conversion').each(function() {
    new bootstrap.Popover(this, {
        placement: 'right',
        trigger: 'click focus',
        html: true,
        title: 'Quantity Divisor',
        content: getPopoverContent,
    });
})

var count = 1;
function getPopoverContent() {
    return count++;
}

I need to update the text every time it is displayed. Does anyone know how to make that work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions