aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAucT <[email protected]>2023-01-03 08:06:09 +0200
committerGitHub <[email protected]>2023-01-02 22:06:09 -0800
commit19d547be3d31bc96a163f56237dd372ba8994d35 (patch)
tree7297b3838820d2f1f3a70c67679cf8e2f7573b30
parente30916b5993f5bb13d652b2597cf1a4ef8326da9 (diff)
downloadbootstrap-19d547be3d31bc96a163f56237dd372ba8994d35.tar.xz
bootstrap-19d547be3d31bc96a163f56237dd372ba8994d35.zip
fix live toast demo (#37590)
* fix live toast demo * Fix live toast demo * Update snippets.js * Update toasts.md * Update snippets.js * Code review comments addressed Co-authored-by: XhmikosR <[email protected]> Co-authored-by: Mark Otto <[email protected]>
-rw-r--r--site/assets/js/snippets.js16
-rw-r--r--site/content/docs/5.3/components/toasts.md6
2 files changed, 11 insertions, 11 deletions
diff --git a/site/assets/js/snippets.js b/site/assets/js/snippets.js
index a69b4bf64..95fce2da8 100644
--- a/site/assets/js/snippets.js
+++ b/site/assets/js/snippets.js
@@ -19,7 +19,7 @@
// --------
// 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)
@@ -28,7 +28,7 @@
// --------
// 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)
@@ -49,7 +49,7 @@
})
}
- // 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, {
@@ -59,14 +59,14 @@
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()
})
}
@@ -98,7 +98,7 @@
// --------
// 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)
diff --git a/site/content/docs/5.3/components/toasts.md b/site/content/docs/5.3/components/toasts.md
index b7a84dc6e..d3454633a 100644
--- a/site/content/docs/5.3/components/toasts.md
+++ b/site/content/docs/5.3/components/toasts.md
@@ -90,11 +90,11 @@ We use the following JavaScript to trigger our live toast demo:
```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()
})
}
```