docs: move note about cancelling modal events to the events' table

This commit is contained in:
Julien Déramond 2025-02-12 18:40:36 +01:00
parent f1b808006b
commit 33c9dbf5b0
No known key found for this signature in database
GPG Key ID: EE5F274EA1F477FA
1 changed files with 1 additions and 8 deletions

View File

@ -856,7 +856,7 @@ Bootstrap's modal class exposes a few events for hooking into modal functionalit
{{< bs-table >}} {{< bs-table >}}
| Event | Description | | Event | Description |
| --- | --- | | --- | --- |
| `hide.bs.modal` | This event is fired immediately when the `hide` instance method has been called. | | `hide.bs.modal` | This event is fired immediately when the `hide` instance method has been called. Can be prevented by calling `event.preventDefault()`. See [JavaScript events documentation]({{< docsref "/getting-started/javascript#events" >}}) for more details on event prevention. |
| `hidden.bs.modal` | This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). | | `hidden.bs.modal` | This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). |
| `hidePrevented.bs.modal` | This event is fired when the modal is shown, its backdrop is `static` and a click outside of the modal is performed. The event is also fired when the escape key is pressed and the `keyboard` option is set to `false`. | | `hidePrevented.bs.modal` | This event is fired when the modal is shown, its backdrop is `static` and a click outside of the modal is performed. The event is also fired when the escape key is pressed and the `keyboard` option is set to `false`. |
| `show.bs.modal` | This event fires immediately when the `show` instance method is called. If caused by a click, the clicked element is available as the `relatedTarget` property of the event. | | `show.bs.modal` | This event fires immediately when the `show` instance method is called. If caused by a click, the clicked element is available as the `relatedTarget` property of the event. |
@ -868,11 +868,4 @@ const myModalEl = document.getElementById('myModal')
myModalEl.addEventListener('hidden.bs.modal', event => { myModalEl.addEventListener('hidden.bs.modal', event => {
// do something... // do something...
}) })
myModalEl.addEventListener('hide.bs.modal', event => {
// you can also abort the event...
if (!valid) {
return event.preventDefault()
}
})
``` ```