mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-26 23:04:32 +02:00
Add js-docs shortcode to ensure consistency between doc and js code (#38316)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -481,24 +481,7 @@ Below is a live demo followed by example HTML and JavaScript. For more informati
|
||||
</div>
|
||||
{{< /example >}}
|
||||
|
||||
```js
|
||||
const exampleModal = document.getElementById('exampleModal')
|
||||
exampleModal.addEventListener('show.bs.modal', event => {
|
||||
// Button that triggered the modal
|
||||
const button = event.relatedTarget
|
||||
// Extract info from data-bs-* attributes
|
||||
const recipient = button.getAttribute('data-bs-whatever')
|
||||
// If necessary, you could initiate an Ajax request here
|
||||
// and then do the updating in a callback.
|
||||
//
|
||||
// Update the modal's content.
|
||||
const modalTitle = exampleModal.querySelector('.modal-title')
|
||||
const modalBodyInput = exampleModal.querySelector('.modal-body input')
|
||||
|
||||
modalTitle.textContent = `New message to ${recipient}`
|
||||
modalBodyInput.value = recipient
|
||||
})
|
||||
```
|
||||
{{< js-docs name="varying-modal-content" file="site/assets/js/snippets.js" >}}
|
||||
|
||||
### Toggle between modals
|
||||
|
||||
|
Reference in New Issue
Block a user