1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-21 20:55:50 +02:00

Streamline application.js exampleModal code (#30819)

* use `textContent` since we only need to add text
* move comments
This commit is contained in:
XhmikosR
2020-05-19 08:33:12 +03:00
committed by GitHub
parent 62626db320
commit e271d01606
2 changed files with 10 additions and 5 deletions

View File

@@ -66,14 +66,16 @@
var exampleModal = document.getElementById('exampleModal')
if (exampleModal) {
exampleModal.addEventListener('show.bs.modal', function (event) {
var button = event.relatedTarget // Button that triggered the modal
var recipient = button.getAttribute('data-whatever') // Extract info from data-* attributes
// Button that triggered the modal
var button = event.relatedTarget
// Extract info from data-* attributes
var recipient = button.getAttribute('data-whatever')
// Update the modal's content.
var modalTitle = exampleModal.querySelector('.modal-title')
var modalBodyInput = exampleModal.querySelector('.modal-body input')
modalTitle.innerHTML = 'New message to ' + recipient
modalTitle.textContent = 'New message to ' + recipient
modalBodyInput.value = recipient
})
}