From 4167c107f81aeb2b05e3fe3e2e511b50ea9be640 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Mon, 18 Jan 2021 05:10:01 -0800 Subject: [PATCH] Add a live toast example to the docs (#32760) --- site/assets/js/application.js | 12 ++++++- site/content/docs/5.0/components/toasts.md | 40 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/site/assets/js/application.js b/site/assets/js/application.js index 84774a95d5..6ff3160563 100644 --- a/site/assets/js/application.js +++ b/site/assets/js/application.js @@ -39,7 +39,7 @@ }) } - document.querySelectorAll('.toast') + document.querySelectorAll('.bd-example .toast') .forEach(function (toastNode) { var toast = new bootstrap.Toast(toastNode, { autohide: false @@ -48,6 +48,16 @@ toast.show() }) + var toastTrigger = document.getElementById('liveToastBtn') + var toastLiveExample = document.getElementById('liveToast') + if (toastTrigger) { + toastTrigger.addEventListener('click', function () { + var toast = new bootstrap.Toast(toastLiveExample) + + toast.show() + }) + } + // Demos within modals document.querySelectorAll('.tooltip-test') .forEach(function (tooltip) { diff --git a/site/content/docs/5.0/components/toasts.md b/site/content/docs/5.0/components/toasts.md index 45cef6f453..eb879b6500 100644 --- a/site/content/docs/5.0/components/toasts.md +++ b/site/content/docs/5.0/components/toasts.md @@ -41,6 +41,46 @@ Toasts are as flexible as you need and have very little required markup. At a mi {{< /example >}} +### Live + +Click the button the below to show as toast (positioning with our utilities in the lower right corner) that has been hidden by default with `.hide`. + +
+ +
+ +
+ +
+ +```html + + +
+ +
+``` + ### Translucent Toasts are slightly translucent, too, so they blend over whatever they might appear over. -- 2.47.2