DetectDirtyFormController
Purpose
Track whether any of the inputs elements of a <form>
have changed their value from the value they loaded with.
Adds data-dirty
to any inputs being watched that change value, and removes data-dirty
if it returns to its initial value.
Adds data-dirty
to the form if any of the child inputs are different to the value they loaded with, and removes it when all elements are returned to their initial values.
Action | Purpose |
---|
restore | Return the form and all inputs to their original value |
Value | Type | Description | Default |
---|
- | - | - | - |
Events
Event | When | Dispatched on | event.detail |
---|
input-dirtied | - | the input , textarea or select that changed | target : the input that changed |
input-cleaned | - | the input , textarea or select that changed | target : the input that changed |
form-dirtied | - | the form that changed | target : the form that changed |
form-cleaned | - | the form that changed | target : the form that changed |
Side Effects
Adds input
and change
event listeners to the attached form, bubbled up from any child inputs.
How to Use