Popover + Tooltip : js error multiple instances with selector option.
See original GitHub issuePrerequisites
- I have searched for duplicate or closed issues
- I have validated any HTML to avoid common problems
- I have read the contributing guidelines
Describe the issue
When using selector
option for both popovers and tooltips this way:
new bootstrap.Tooltip(document.body, {
selector: '[data-bs-toggle="tooltip"]'
});
new bootstrap.Popover(document.body, {
selector: '[data-bs-toggle="popover"]'
});
We get the following js error (check browser console to see the error):
Bootstrap doesn’t allow more than one instance per element. Bound instance: bs.tooltip.
Because we use document.body
in both cases.
Reduced test cases
https://codepen.io/florianlacreuse/pen/jOaNzVm
What operating system(s) are you seeing the problem on?
Linux
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
5.1.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (14 by maintainers)
Top Results From Across the Web
Bootstrap tooltips not working - Stack Overflow
Bootstrap tooltips are expensive because you need to handle mouse events on each of the elements. This is the reason why they haven't...
Read more >Popovers - Bootstrap
Documentation and examples for adding Bootstrap popovers, like those found in iOS, to any element on your site.
Read more >Bootstrap JS Popover Reference - W3Schools
Name Type Default Try it
animation boolean true Try it
container string, or the boolean false false Try it
content string "" Try it
Read more >JavaScript · Bootstrap 3.3.6 Documentation - BootstrapDocs
Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a...
Read more >BSN - Native JavaScript for Bootstrap - GitHub Pages
The faster, lighter and more compact version of the Bootstrap JavaScript ... around determining the specific HTMLElement target or setting instance options.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry to bring this up again, but using Blazor and the selector option is really required for both the components to work since most of the times elements may not be present on the page. So, if I can’t use this
what is the official alternative since this is the approach mentioned in documentation?
Thank you in advance!
Same problem as @HybridSolutions.