mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 13:13:03 +02:00
Streamline application.js exampleModal code (#30819)
* use `textContent` since we only need to add text * move comments
This commit is contained in:
@@ -66,14 +66,16 @@
|
|||||||
var exampleModal = document.getElementById('exampleModal')
|
var exampleModal = document.getElementById('exampleModal')
|
||||||
if (exampleModal) {
|
if (exampleModal) {
|
||||||
exampleModal.addEventListener('show.bs.modal', function (event) {
|
exampleModal.addEventListener('show.bs.modal', function (event) {
|
||||||
var button = event.relatedTarget // Button that triggered the modal
|
// Button that triggered the modal
|
||||||
var recipient = button.getAttribute('data-whatever') // Extract info from data-* attributes
|
var button = event.relatedTarget
|
||||||
|
// Extract info from data-* attributes
|
||||||
|
var recipient = button.getAttribute('data-whatever')
|
||||||
|
|
||||||
// Update the modal's content.
|
// Update the modal's content.
|
||||||
var modalTitle = exampleModal.querySelector('.modal-title')
|
var modalTitle = exampleModal.querySelector('.modal-title')
|
||||||
var modalBodyInput = exampleModal.querySelector('.modal-body input')
|
var modalBodyInput = exampleModal.querySelector('.modal-body input')
|
||||||
|
|
||||||
modalTitle.innerHTML = 'New message to ' + recipient
|
modalTitle.textContent = 'New message to ' + recipient
|
||||||
modalBodyInput.value = recipient
|
modalBodyInput.value = recipient
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -547,8 +547,11 @@ exampleModal.addEventListener('show.bs.modal', function (event) {
|
|||||||
// and then do the updating in a callback.
|
// and then do the updating in a callback.
|
||||||
//
|
//
|
||||||
// Update the modal's content.
|
// Update the modal's content.
|
||||||
exampleModal.querySelector('.modal-title').textContent = 'New message to ' + recipient
|
var modalTitle = exampleModal.querySelector('.modal-title')
|
||||||
exampleModal.querySelector('.modal-body input').value = recipient
|
var modalBodyInput = exampleModal.querySelector('.modal-body input')
|
||||||
|
|
||||||
|
modalTitle.textContent = 'New message to ' + recipient
|
||||||
|
modalBodyInput.value = recipient
|
||||||
})
|
})
|
||||||
{{< /highlight >}}
|
{{< /highlight >}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user