diff options
| author | XhmikosR <[email protected]> | 2021-07-29 09:14:40 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-29 09:14:40 +0300 |
| commit | ef5336373fc2431b3d1d37cde85cd262210a1dc6 (patch) | |
| tree | e325fb4c5532b464d05780c731d0f118f2a88d7f /site/content/docs/5.0/components/toasts.md | |
| parent | 62edf07d7491684fe67a9c1e9439ed2bd10ca741 (diff) | |
| parent | c6c0bbb0b67fe89b55740a63fd10d4ad79044970 (diff) | |
| download | bootstrap-main-fod-simpler-table-structure.tar.xz bootstrap-main-fod-simpler-table-structure.zip | |
Merge branch 'main' into main-fod-simpler-table-structuremain-fod-simpler-table-structure
Diffstat (limited to 'site/content/docs/5.0/components/toasts.md')
| -rw-r--r-- | site/content/docs/5.0/components/toasts.md | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/site/content/docs/5.0/components/toasts.md b/site/content/docs/5.0/components/toasts.md index 2dde09f5b..d17d8b3df 100644 --- a/site/content/docs/5.0/components/toasts.md +++ b/site/content/docs/5.0/components/toasts.md @@ -41,12 +41,16 @@ Toasts are as flexible as you need and have very little required markup. At a mi </div> {{< /example >}} -### Live +{{< callout warning >}} +Previously, our scripts dynamically added the `.hide` class to completely hide a toast (with `display:none`, rather than just with `opacity:0`). This is now not necessary anymore. However, for backwards compatibility, our script will continue to toggle the class (even though there is no practical need for it) until the next major version. +{{< /callout >}} + +### Live example -Click the button below to show a toast (positioned with our utilities in the lower right corner) that has been hidden by default with `.hide`. +Click the button below to show a toast (positioned with our utilities in the lower right corner) that has been hidden by default. <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11"> - <div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true"> + <div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> {{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}} <strong class="me-auto">Bootstrap</strong> @@ -67,7 +71,7 @@ Click the button below to show a toast (positioned with our utilities in the low <button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button> <div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11"> - <div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true"> + <div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true"> <div class="toast-header"> <img src="..." class="rounded me-2" alt="..."> <strong class="me-auto">Bootstrap</strong> @@ -81,6 +85,20 @@ Click the button below to show a toast (positioned with our utilities in the low </div> ``` +We use the following JavaScript to trigger our live toast demo: + +```js +var toastTrigger = document.getElementById('liveToastBtn') +var toastLiveExample = document.getElementById('liveToast') +if (toastTrigger) { + toastTrigger.addEventListener('click', function () { + var toast = new bootstrap.Toast(toastLiveExample) + + toast.show() + }) +} +``` + ### Translucent Toasts are slightly translucent to blend in with what's below them. @@ -323,6 +341,10 @@ var toastList = toastElList.map(function (toastEl) { }) ``` +### Triggers + +{{% js-dismiss "toast" %}} + ### Options Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-bs-`, as in `data-bs-animation=""`. @@ -393,7 +415,7 @@ toast.dispose() #### getInstance -*Static* method which allows you to get the scrollspy instance associated with a DOM element +*Static* method which allows you to get the toast instance associated with a DOM element ```js var myToastEl = document.getElementById('myToastEl') @@ -402,7 +424,7 @@ var myToast = bootstrap.Toast.getInstance(myToastEl) // Returns a Bootstrap toas #### getOrCreateInstance -*Static* method which allows you to get the scrollspy instance associated with a DOM element, or create a new one in case it wasn't initialised +*Static* method which allows you to get the toast instance associated with a DOM element, or create a new one in case it wasn't initialised ```js var myToastEl = document.getElementById('myToastEl') |
