Bootstrap 5 popover with HTML content as data attribute

408 views Asked by At

I want to show a Bootstrap 5 popover with custom HTML content. That means using the content option, and I can do that successfully the normal way (using javascript).

But I want to specify it in markup instead, as data-bs-content, without javascript. I tried this:

<a role="button"
   tabindex="0"
   data-bs-html="true"
   data-bs-sanitize="false"
   data-bs-content="() => document.getElementById('foo').innerHTML"
   >Show popover</a>

<div id="foo" class="d-none">
  ...popover's content...
</div>

But the popover shows the literal text () => document.getElementById('foo').innerHTML.

Is my syntax incorrect, or is this impossible?

0

There are 0 answers