I have the following StimulusJS controller that aims to track certain required elements (flatckpickr date selectors).
Once all those date pickers' dates have been selected, I have to enable the submit button in a form.
I'm having problems tracking that all the required inputs have been inputed by the user and since this should be a reutilizable controller, I can't hardcode a value and compare against it.
What would be an effective way to check that all requiredTargets have received input from the user?
import { Controller } from 'stimulus';
export default class extends Controller {
static targets = ["required", "deactivable"];
toggle(){
this.deactivableTargets.toggleAttribute("disabled");
}
connect() {
this.requiredTargets.forEach((element) => {
element.addEventListener('input', (event) => {
console.log(`${element} changed`);
//if (this.requiredTargets.inputed?) {
toggle();
}
})
})
}
}