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

18 lines
627 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');
2019-09-24 16:38:58 +02:00
syncInputToElement('#procedure_description', '.procedure-description-body');
}
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);