You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/alerts.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -211,6 +211,15 @@ See the [triggers](#triggers) section for more details.
211
211
212
212
### Methods
213
213
214
+
You can create an alert instance with the alert constructor, for example:
215
+
216
+
```js
217
+
var myAlert =document.getElementById('myAlert')
218
+
var bsAlert =newbootstrap.Alert(myAlert)
219
+
```
220
+
221
+
This makes an alert listen for click events on descendant elements which have the `data-bs-dismiss="alert"` attribute. (Not necessary when using the data-api’s auto-initialization.)
222
+
214
223
{{< bs-table >}}
215
224
| Method | Description |
216
225
| --- | --- |
@@ -220,9 +229,11 @@ See the [triggers](#triggers) section for more details.
220
229
|`getOrCreateInstance`| Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn't initialised. You can use it like this: <code>bootstrap.Alert.getOrCreateInstance(element)</code>. |
221
230
{{< /bs-table >}}
222
231
232
+
Basic usage:
233
+
223
234
```js
224
235
var alertNode =document.querySelector('.alert')
225
-
var alert =bootstrap.Alert.getInstance(alertNode)
236
+
var alert =bootstrap.Alert.getOrCreateInstance(alertNode)
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/buttons.md
+2-3Lines changed: 2 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,9 +174,8 @@ var bsButton = new bootstrap.Button(button)
174
174
| --- | --- |
175
175
|`toggle`| Toggles push state. Gives the button the appearance that it has been activated. |
176
176
|`dispose`| Destroys an element's button. (Removes stored data on the DOM element) |
177
-
|`getInstance`| Static method which allows you to get the button instance associated to a DOM element, you can use it like this: <code>bootstrap.Button.getInstance(element)</code>|
178
-
| `getOrCreateInstance` | Static method which returns a button instance associated to a DOM element or create a new one in case it wasn't initialised.
179
-
You can use it like this: <code>bootstrap.Button.getOrCreateInstance(element)</code> |
177
+
|`getInstance`| Static method which allows you to get the button instance associated to a DOM element, you can use it like this: `bootstrap.Button.getInstance(element)`|
178
+
|`getOrCreateInstance`| Static method which returns a button instance associated to a DOM element or create a new one in case it wasn't initialised. You can use it like this: `bootstrap.Button.getOrCreateInstance(element)`|
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/collapse.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,8 +175,7 @@ var bsCollapse = new bootstrap.Collapse(myCollapse, {
175
175
|`hide`| Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (e.g., before the `hidden.bs.collapse` event occurs). |
176
176
|`dispose`| Destroys an element's collapse. (Removes stored data on the DOM element) |
177
177
|`getInstance`| Static method which allows you to get the collapse instance associated to a DOM element, you can use it like this: `bootstrap.Collapse.getInstance(element)`|
178
-
| `getOrCreateInstance` | Static method which returns a collapse instance associated to a DOM element or create a new one in case it wasn't initialised.
179
-
You can use it like this: `bootstrap.Collapse.getOrCreateInstance(element)` |
178
+
|`getOrCreateInstance`| Static method which returns a collapse instance associated to a DOM element or create a new one in case it wasn't initialised. You can use it like this: `bootstrap.Collapse.getOrCreateInstance(element)`|
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/dropdowns.md
+4-11Lines changed: 4 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1025,17 +1025,10 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
1025
1025
|`boundary`| string, element |`'scrollParent'`| Overflow constraint boundary of the dropdown menu (applies only to Popper's preventOverflow modifier). By default it's `clippingParents` and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper's [detectOverflow docs](https://popper.js.org/docs/v2/utils/detect-overflow/#boundary). |
1026
1026
|`reference`| string, element |`'toggle'`| Reference element of the dropdown menu. Accepts the values of `'toggle'`, `'parent'`, an HTMLElement reference or an object providing `getBoundingClientRect`. For more information refer to Popper's [constructor docs](https://popper.js.org/docs/v2/constructors/#createpopper) and [virtual element docs](https://popper.js.org/docs/v2/virtual-elements/). |
1027
1027
|`display`| string |`'dynamic'`| By default, we use Popper for dynamic positioning. Disable this with `static`. |
1028
-
| `offset` | number, string, function | `[0, 2]` | Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"`
1029
-
When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1), [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1).
1030
-
For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options). |
1031
-
| `autoClose` | boolean, string | `true` | Configure the auto close behavior of the dropdown:
1032
-
*`true` - the dropdown will be closed by clicking outside or inside the dropdown menu.
1033
-
*`false` - the dropdown will be closed by clicking the toggle button and manually calling `hide` or `toggle` method. (Also will not be closed by pressing <kbd>esc</kbd> key)
1034
-
*`'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.
1035
-
*`'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu.
1036
-
|
1037
-
| `popperConfig` | null, object, function | `null` | To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options)
1038
-
When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper. |
1028
+
|`offset`| number, string, function |`[0, 2]`| Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"` <br> When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1), [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1). <br>For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options). |
1029
+
| `autoClose` | boolean, string | `true` | Configure the auto close behavior of the dropdown: <ul> <li>`true` - the dropdown will be closed by clicking outside or inside the dropdown menu.</li><li>`false` - the dropdown will be closed by clicking the toggle button and manually calling `hide` or `toggle` method. (Also will not be closed by pressing <kbd>esc</kbd> key)</li><li>`'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.</li> <li>`'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu.</li></ul>
1030
+
|
1031
+
|`popperConfig`| null, object, function |`null`| To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options) <br>When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper. |
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/modal.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -863,8 +863,7 @@ var myModal = new bootstrap.Modal(document.getElementById('myModal'), {
863
863
| Method | Description |
864
864
| --- | --- |
865
865
|`toggle`| Manually toggles a modal. **Returns to the caller before the modal has actually been shown or hidden** (i.e. before the `shown.bs.modal` or `hidden.bs.modal` event occurs). |
866
-
| `show` | Manually opens a modal. **Returns to the caller before the modal has actually been shown** (i.e. before the `shown.bs.modal` event occurs).
867
-
Also, you can pass a DOM element as an argument that can be received in the modal events (as the `relatedTarget` property). (i.e. `var modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle)` |
866
+
|`show`| Manually opens a modal. **Returns to the caller before the modal has actually been shown** (i.e. before the `shown.bs.modal` event occurs). Also, you can pass a DOM element as an argument that can be received in the modal events (as the `relatedTarget` property). (i.e. `var modalToggle = document.getElementById('toggleMyModal'); myModal.show(modalToggle)`|
868
867
|`hide`| Manually hides a modal. **Returns to the caller before the modal has actually been hidden** (i.e. before the `hidden.bs.modal` event occurs). |
869
868
|`handleUpdate`| Manually readjust the modal's position if the height of a modal changes while it is open (i.e. in case a scrollbar appears). |
870
869
|`dispose`| Destroys an element's modal. (Removes stored data on the DOM element) |
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/popovers.md
+4-9Lines changed: 4 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,20 +155,15 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
155
155
|`selector`| string, false |`false`| If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to also apply popovers to dynamically added DOM elements (`jQuery.on` support). See [this issue]({{< param repo >}}/issues/4215) and [an informative example](https://codepen.io/Johann-S/pen/djJYPb). |
156
156
|`template`| string |`'<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>'`| Base HTML to use when creating the popover. The popover's `title` will be injected into the `.popover-inner`. `.popover-arrow` will become the popover's arrow. The outermost wrapper element should have the `.popover` class and `role="popover"`. |
157
157
|`title`| string, element, function |`''`| Default title value if `title` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
158
-
| `customClass` | string, function | `''` | Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: `'class-1 class-2'`
159
-
You can also pass a function that should return a single string containing additional class names. |
158
+
|`customClass`| string, function |`''`| Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: `'class-1 class-2'` <br>You can also pass a function that should return a single string containing additional class names. |
160
159
|`trigger`| string |`'hover focus'`| How popover is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. `'manual'` indicates that the popover will be triggered programmatically via the `.popover('show')`, `.popover('hide')` and `.popover('toggle')` methods; this value cannot be combined with any other trigger. `'hover'` on its own will result in popovers that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present. |
161
-
| `offset` | number, string, function | `[0, 0]` | Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"`
162
-
When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1)", [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1).
163
-
For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options).. |
164
-
| `fallbackPlacements` | string, array | `['top', 'right', 'bottom', 'left']` | Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to
|`offset`| number, string, function |`[0, 0]`| Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: `data-bs-offset="10,20"` <br>When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: [skidding](https://popper.js.org/docs/v2/modifiers/offset/#skidding-1)", [distance](https://popper.js.org/docs/v2/modifiers/offset/#distance-1). <br>For more information refer to Popper's [offset docs](https://popper.js.org/docs/v2/modifiers/offset/#options).. |
161
+
|`fallbackPlacements`| string, array |`['top', 'right', 'bottom', 'left']`| Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to <br>Popper's [behavior docs](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements.|
166
162
|`boundary`| string, element |`'clippingParents'`| Overflow constraint boundary of the popover (applies only to Popper's preventOverflow modifier). By default, it's `'clippingParents'` and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper's [detectOverflow docs](https://popper.js.org/docs/v2/utils/detect-overflow/#boundary). |
167
163
|`sanitize`| boolean |`true`| Enable or disable the sanitization. If activated `'template'`, `'content'` and `'title'` options will be sanitized. |
168
164
|`allowList`| object |[Default value]({{< docsref "/getting-started/javascript#sanitizer" >}}) | Object which contains allowed attributes and tags. |
169
165
|`sanitizeFn`| null, function |`null`| Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. |
170
-
| `popperConfig` | null, object, function | `null` | To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options).
171
-
When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.|
166
+
|`popperConfig`| null, object, function |`null`| To change Bootstrap's default Popper config, see [Popper's configuration](https://popper.js.org/docs/v2/constructors/#options). <br>When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.|
Copy file name to clipboardExpand all lines: site/content/docs/5.1/components/toasts.md
+2-18Lines changed: 2 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,26 +369,10 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
369
369
|`show`| Reveals an element's toast. **Returns to the caller before the toast has actually been shown** (i.e. before the `shown.bs.toast` event occurs). You have to manually call this method, instead your toast won't show. |
370
370
|`hide`| Hides an element's toast. **Returns to the caller before the toast has actually been hidden** (i.e. before the `hidden.bs.toast` event occurs). You have to manually call this method if you made `autohide` to `false`. |
371
371
|`dispose`| Hides an element's toast. Your toast will remain on the DOM but won't show anymore. |
372
+
|`getInstance`|*Static* method which allows you to get the scrollspy instance associated with a DOM element. <br> Par example: `var myToastEl = document.getElementById('myToastEl')``var myToast = bootstrap.Toast.getInstance(myToastEl)` Returns a Bootstrap toast instance|
373
+
|`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. <br>`var myToastEl = document.getElementById('myToastEl')``var myToast = bootstrap.Toast.getOrCreateInstance(myToastEl)` Returns a Bootstrap toast instance |
372
374
{{< /bs-table >}}
373
375
374
-
#### getInstance
375
-
376
-
*Static* method which allows you to get the toast instance associated with a DOM element
377
-
378
-
```js
379
-
var myToastEl =document.getElementById('myToastEl')
380
-
var myToast =bootstrap.Toast.getInstance(myToastEl) // Returns a Bootstrap toast instance
381
-
```
382
-
383
-
#### getOrCreateInstance
384
-
385
-
*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
386
-
387
-
```js
388
-
var myToastEl =document.getElementById('myToastEl')
389
-
var myToast =bootstrap.Toast.getOrCreateInstance(myToastEl) // Returns a Bootstrap toast instance
0 commit comments