Add missing form.js for field value update (:focus style)

This commit is contained in:
Alice Gaudon 2020-04-25 09:38:04 +02:00
parent 95cddfe4e2
commit 162063025c
2 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import './external_links'; import './external_links';
import './message_icons'; import './message_icons';
import './forms';
import '../sass/app.scss'; import '../sass/app.scss';

11
assets/js/forms.js Normal file
View File

@ -0,0 +1,11 @@
// For labels to update their state (css selectors based on the value attribute)
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('input').forEach(el => {
if (el.type !== 'checkbox') {
el.setAttribute('value', el.value);
el.addEventListener('change', () => {
el.setAttribute('value', el.value);
});
}
});
});