diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-06-06 23:48:54 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-06-06 23:48:54 +0300 |
commit | af261c1b314058c3aefef3377b9f7f8a20701481 (patch) | |
tree | f7364a518e02ef24d0acc7d760d452a39ee05faf /app/assets/javascripts | |
parent | ff582303a8340fdd4d7fc3c7fb32b07c4c2270fa (diff) |
attach a single event handler to detect radio button changes instead of one per input
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js index 6d227177cb4..152f76ff7af 100644 --- a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js +++ b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js @@ -24,15 +24,15 @@ document.addEventListener('DOMContentLoaded', () => { }); // hide extra auto devops settings based on data-attributes - const autoDevOpsSettings = document.querySelectorAll('input[data-hide-extra-settings]'); + const autoDevOpsSettings = document.querySelector('.js-auto-devops-settings'); const autoDevOpsExtraSettings = document.querySelector('.js-extra-settings'); - autoDevOpsSettings.forEach(input => { - input.addEventListener('click', () => - autoDevOpsExtraSettings.classList.toggle( - 'hidden', - input.dataset.hideExtraSettings === 'true', - ), - ); + autoDevOpsSettings.addEventListener('click', event => { + const targetData = event.target && event.target.dataset; + if (targetData.hideExtraSettings === 'true') { + autoDevOpsExtraSettings.classList.add('hidden'); + } else if (targetData.hideExtraSettings === 'false') { + autoDevOpsExtraSettings.classList.remove('hidden'); + } }); }); |