diff options
| author | XhmikosR <[email protected]> | 2020-05-19 08:33:12 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-19 08:33:12 +0300 |
| commit | e271d016062b0628024a7b3fd1a494e8240c9673 (patch) | |
| tree | 847b857af5b875ceec433367be6d4b56c2ba4e2c | |
| parent | 62626db320ee982a5576fa9c71f5bd7530056009 (diff) | |
| download | bootstrap-e271d016062b0628024a7b3fd1a494e8240c9673.tar.xz bootstrap-e271d016062b0628024a7b3fd1a494e8240c9673.zip | |
Streamline application.js exampleModal code (#30819)
* use `textContent` since we only need to add text
* move comments
| -rw-r--r-- | site/assets/js/application.js | 8 | ||||
| -rw-r--r-- | site/content/docs/5.0/components/modal.md | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/site/assets/js/application.js b/site/assets/js/application.js index 9d0c684b7..51dc20d42 100644 --- a/site/assets/js/application.js +++ b/site/assets/js/application.js @@ -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 }) } diff --git a/site/content/docs/5.0/components/modal.md b/site/content/docs/5.0/components/modal.md index ece511ca2..e42c104c5 100644 --- a/site/content/docs/5.0/components/modal.md +++ b/site/content/docs/5.0/components/modal.md @@ -547,8 +547,11 @@ exampleModal.addEventListener('show.bs.modal', function (event) { // and then do the updating in a callback. // // Update the modal's content. - exampleModal.querySelector('.modal-title').textContent = 'New message to ' + recipient - exampleModal.querySelector('.modal-body input').value = recipient + var modalTitle = exampleModal.querySelector('.modal-title') + var modalBodyInput = exampleModal.querySelector('.modal-body input') + + modalTitle.textContent = 'New message to ' + recipient + modalBodyInput.value = recipient }) {{< /highlight >}} |
