-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide proper documentation for using Tooltip with selector #41020
Comments
Does the "enable tooltips" example in the docs not meet your needs? https://getbootstrap.com/docs/5.3/components/tooltips/#enable-tooltips const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) If not, it'd be helpful to hear more about exactly what you're trying to achieve. |
@nwalters512 No, as this doesn't take care of elements added dynamically to the page later on. |
Gotcha. IMO this is outside the realm of what Bootstrap can be expected to document, but I've used https://www.npmjs.com/package/selector-observer for this: import { observe } from 'selector-observer';
observe('[data-bs-toggle="tooltip"]', {
add(el) {
new window.bootstrap.Tooltip(el);
},
remove(el) {
window.bootstrap.Tooltip.getInstance(el)?.dispose();
},
}); |
Well that doesn't really document the |
🙈 never mind; today I learned something new about the Bootstrap API! Yes, it'd be great for this to be formally documented. |
Prerequisites
Describe the issue
There is currently no documentation on how to use Tooltip with 'selector' using plain JS.
Reduced test cases
This unfortunately doesn't work:
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Firefox
What version of Bootstrap are you using?
5.3.3
The text was updated successfully, but these errors were encountered: