demarches-normaliennes/app/javascript/new_design/procedure-form.js
2019-10-31 10:27:19 +01:00

17 lines
627 B
JavaScript

import { delegate } from '@utils';
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', '.procedure-description-body');
}
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);