Fix handling of input toggle on cached form
This commit is contained in:
parent
4f230af334
commit
c215b21869
|
@ -6,9 +6,11 @@
|
||||||
// Allows a form checkbox to toggle an input element.
|
// Allows a form checkbox to toggle an input element.
|
||||||
// This requires the form to have a structure like described in the bootstrap documentation:
|
// This requires the form to have a structure like described in the bootstrap documentation:
|
||||||
// https://getbootstrap.com/docs/5.3/forms/input-group/#checkboxes-and-radios
|
// https://getbootstrap.com/docs/5.3/forms/input-group/#checkboxes-and-radios
|
||||||
|
const inputToggle = target => {
|
||||||
|
target.parentElement.parentElement.querySelector("input:not(.input-toggle)").disabled = !target.checked
|
||||||
|
}
|
||||||
Array.from(document.getElementsByClassName("input-toggle")).forEach(el => {
|
Array.from(document.getElementsByClassName("input-toggle")).forEach(el => {
|
||||||
el.addEventListener("change", e => {
|
inputToggle(el)
|
||||||
e.target.parentElement.parentElement.querySelector("input:not(.input-toggle)").disabled = !e.target.checked;
|
el.addEventListener("change", e => inputToggle(e.target))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})()
|
})()
|
||||||
|
|
Loading…
Reference in a new issue