From: XhmikosR Date: Tue, 19 May 2020 05:33:12 +0000 (+0300) Subject: Streamline application.js exampleModal code (#30819) X-Git-Tag: v5.0.0-alpha1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e271d016062b0628024a7b3fd1a494e8240c9673;p=thirdparty%2Fbootstrap.git Streamline application.js exampleModal code (#30819) * use `textContent` since we only need to add text * move comments --- diff --git a/site/assets/js/application.js b/site/assets/js/application.js index 9d0c684b72..51dc20d42d 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 ece511ca2f..e42c104c51 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 >}}