diff --git a/_dev/js/theme/components/useThemeForm.js b/_dev/js/theme/components/useThemeForm.js index 1a2ca365..4e58f073 100644 --- a/_dev/js/theme/components/useThemeForm.js +++ b/_dev/js/theme/components/useThemeForm.js @@ -1,4 +1,5 @@ import { each } from '../utils/DOMHelpers'; +import $ from "jquery"; const supportedValidity = () => { const input = document.createElement('input'); @@ -88,10 +89,24 @@ const useThemeForm = ( validationFormSelector = '.js-needs-validation', passwordToggleSelector = '[data-action="show-password"]', ) => { + const DOM_SELECTORS = { + SELECT_LINK: '.js-select-link', + } + + const handleSelectChange = (event) => { + const target = event.target; + + if (target) { + window.location.href = target.value; + } + } const init = () => { - each(document.querySelectorAll(passwordToggleSelector), togglePasswordVisibility) - each(document.querySelectorAll(validationFormSelector), formValidation) + each(document.querySelectorAll(passwordToggleSelector), togglePasswordVisibility); + each(document.querySelectorAll(validationFormSelector), formValidation); + each(document.querySelectorAll(DOM_SELECTORS.SELECT_LINK), (select) => { + select.addEventListener('change', handleSelectChange); + }); } return { diff --git a/_dev/js/theme/index.js b/_dev/js/theme/index.js index b7cc612d..9072b7e1 100644 --- a/_dev/js/theme/index.js +++ b/_dev/js/theme/index.js @@ -41,8 +41,4 @@ $(() => { initForm(); bsCustomFileInput.init(); usePasswordPolicy('.field-password-policy'); - - $('.js-select-link').on('change', ({ target }) => { - window.location.href = $(target).val(); - }); });