demarches-normaliennes/app/javascript/new_design/champs/drop-down-list.js

21 lines
597 B
JavaScript
Raw Normal View History

import { delegate, show, hide } from '@utils';
delegate(
'change',
'.editable-champ-drop_down_list select, .editable-champ-drop_down_list input[type="radio"]',
(event) => {
const parent = event.target.closest('.editable-champ-drop_down_list');
const inputGroup = parent?.querySelector('.drop_down_other');
if (inputGroup) {
const input = inputGroup.querySelector('input');
if (event.target.value === '__other__') {
show(inputGroup);
input.disabled = false;
} else {
hide(inputGroup);
input.disabled = true;
}
}
}
);