demarches-normaliennes/app/javascript/new_design/procedure-form.js

27 lines
834 B
JavaScript
Raw Normal View History

import { delegate } from '@utils';
2019-09-24 16:38:58 +02:00
function syncInputToElement(fromSelector, toSelector) {
const fromElement = document.querySelector(fromSelector);
const toElement = document.querySelector(toSelector);
if (toElement && fromElement) {
toElement.innerText = fromElement.value;
}
}
function syncFormToPreview() {
syncInputToElement('#procedure_libelle', '.procedure-title');
syncInputToElement('#procedure_description', '.js_description p');
2023-05-22 16:26:50 +02:00
syncInputToElement(
'#procedure_description_target_audience',
'.js_description_target_audience p'
2023-05-22 16:26:50 +02:00
);
2019-09-24 16:38:58 +02:00
}
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);
2023-05-22 16:26:50 +02:00
delegate(
'input',
'.procedure-form #procedure_description_target_audience',
2023-05-22 16:26:50 +02:00
syncFormToPreview
);