mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-17 19:21:23 +03:00
Rewrite docs tables in Markdown with table shortcode (#31337)
Co-authored-by: XhmikosR <xhmikosr@gmail.com> Co-authored-by: GeoSot <geo.sotis@gmail.com>
This commit is contained in:
@@ -209,53 +209,29 @@ See the [triggers](#triggers) section for more details.
|
||||
|
||||
### Methods
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Method</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>close</code>
|
||||
</td>
|
||||
<td>
|
||||
Closes an alert by removing it from the DOM. If the <code>.fade</code> and <code>.show</code> classes are present on the element, the alert will fade out before it is removed.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>dispose</code>
|
||||
</td>
|
||||
<td>
|
||||
Destroys an element's alert. (Removes stored data on the DOM element)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>getInstance</code>
|
||||
</td>
|
||||
<td>
|
||||
Static method which allows you to get the alert instance associated to a DOM element, you can use it like this: <code>bootstrap.Alert.getInstance(alert)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>getOrCreateInstance</code>
|
||||
</td>
|
||||
<td>
|
||||
Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn't initialized.
|
||||
You can use it like this: <code>bootstrap.Alert.getOrCreateInstance(element)</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
You can create an alert instance with the alert constructor, for example:
|
||||
|
||||
```js
|
||||
var myAlert = document.getElementById('myAlert')
|
||||
var bsAlert = new bootstrap.Alert(myAlert)
|
||||
```
|
||||
|
||||
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.)
|
||||
|
||||
{{< bs-table >}}
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| `close` | Closes an alert by removing it from the DOM. If the `.fade` and `.show` classes are present on the element, the alert will fade out before it is removed. |
|
||||
| `dispose` | Destroys an element's alert. (Removes stored data on the DOM element) |
|
||||
| `getInstance` | Static method which allows you to get the alert instance associated to a DOM element. For example: `bootstrap.Alert.getInstance(alert)`. |
|
||||
| `getOrCreateInstance` | Static method which returns an alert instance associated to a DOM element or create a new one in case it wasn't initialized. You can use it like this: <code>bootstrap.Alert.getOrCreateInstance(element)</code>. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
Basic usage:
|
||||
|
||||
```js
|
||||
var alertNode = document.querySelector('.alert')
|
||||
var alert = bootstrap.Alert.getInstance(alertNode)
|
||||
var alert = bootstrap.Alert.getOrCreateInstance(alertNode)
|
||||
alert.close()
|
||||
```
|
||||
|
||||
@@ -263,28 +239,12 @@ alert.close()
|
||||
|
||||
Bootstrap's alert plugin exposes a few events for hooking into alert functionality.
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Event</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>close.bs.alert</code></td>
|
||||
<td>
|
||||
Fires immediately when the <code>close</code> instance method is called.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>closed.bs.alert</code></td>
|
||||
<td>
|
||||
Fired when the alert has been closed and CSS transitions have completed.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{< bs-table >}}
|
||||
| Event | Description |
|
||||
| --- | --- |
|
||||
| `close.bs.alert` | Fires immediately when the `close` instance method is called. |
|
||||
| `closed.bs.alert` | Fired when the alert has been closed and CSS transitions have completed. |
|
||||
{{< /bs-table >}}
|
||||
|
||||
```js
|
||||
var myAlert = document.getElementById('myAlert')
|
||||
|
||||
Reference in New Issue
Block a user