// --------
// Tooltips
// --------
- // Instantiate all tooltips in a docs or StackBlitz page
+ // Instantiate all tooltips in a docs or StackBlitz
document.querySelectorAll('[data-bs-toggle="tooltip"]')
.forEach(tooltip => {
new bootstrap.Tooltip(tooltip)
// --------
// Popovers
// --------
- // Instantiate all popovers in a docs or StackBlitz page
+ // Instantiate all popovers in docs or StackBlitz
document.querySelectorAll('[data-bs-toggle="popover"]')
.forEach(popover => {
new bootstrap.Popover(popover)
})
}
- // Instantiate all toasts in a docs page only
+ // Instantiate all toasts in docs pages only
document.querySelectorAll('.bd-example .toast')
.forEach(toastNode => {
const toast = new bootstrap.Toast(toastNode, {
toast.show()
})
- // Instantiate all toasts in a docs page only
+ // Instantiate all toasts in docs pages only
const toastTrigger = document.getElementById('liveToastBtn')
const toastLiveExample = document.getElementById('liveToast')
+
if (toastTrigger) {
+ const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastTrigger.addEventListener('click', () => {
- const toast = new bootstrap.Toast(toastLiveExample)
-
- toast.show()
+ toastBootstrap.show()
})
}
// --------
// Carousels
// --------
- // Instantiate all non-autoplaying carousels in a docs or StackBlitz page
+ // Instantiate all non-autoplaying carousels in docs or StackBlitz
document.querySelectorAll('.carousel:not([data-bs-ride="carousel"])')
.forEach(carousel => {
bootstrap.Carousel.getOrCreateInstance(carousel)
```js
const toastTrigger = document.getElementById('liveToastBtn')
const toastLiveExample = document.getElementById('liveToast')
+
if (toastTrigger) {
+ const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastTrigger.addEventListener('click', () => {
- const toast = new bootstrap.Toast(toastLiveExample)
-
- toast.show()
+ toastBootstrap.show()
})
}
```