In Bootstrap 4, I was able to do the following to create multiple tooltips on doc ready:
$('div.sidebar-menu i[data-toggle="tooltip"]')
.tooltip({ boundary: "viewport", delay: { "show": 500, "hide": 100 }, placement: "right" })
.on("show.bs.tooltip", function (this: HTMLElement) {
const css = toggler.data("toggle");
return $(toggler.data("target")).hasClass(css);
});
But with the "removal" of jQuery, I'm trying to do it the new way, and it seems like you can't pass a selector to the new Bootstrap constructor that allows for multiple elements.
This doesn't work. (It only creates one instance.)
var tips = new bootstrap.Tooltip('div.sidebar-menu i[data-bs-toggle="tooltip"]', { delay: { "show": 500, "hide": 100 }, placement: "right" });
Do we really have to do a for loop now to instantiate multiple instances? All the examples on Bootstrap's site are only for one instance at a time.
CodePudding user response:
You need use a JS selector instead of the JQUERY selector. Take a look at the original bootstrap example:
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})