Add blur event for validation libraries
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] Bug report => search github for a similar issue or PR before submitting
[x] Feature request
[ ] Other, please describe
A PR (#22) was opened a while back adding the blur
event, and you said you couldn’t see a use case and that it would mean other events would need adding. In our application, there is a use case for this, and that is when using the vuelidate
where validations can be triggered when a field is blurred. Currently I cannot apply this with vue-flatpickr due to this event not being registered/emit.
I don’t disagree with your statement that it may make sense then to allow other events to be added such as keyboard events, however since Vue 2.4 it is possible to simply bind all listeners provided to a component via the $listeners
property.
This would allow the developer to decide which listener they wish to bind rather than vue-flatpickr having to pick and choose. I don’t know the all of the code, but at a quick glance it would as simple as changing the template of the component to
<input type="text" data-input v-on="inputListeners">
and adding a computed property
inputListeners() {
let vm = this;
return Object.assign({},
vm.$listeners,
{
input: vm.onInput,
}
);
}
With this change, I would be able to do something like
<flat-pickr
v-model="model"
:config="config"
@blur="onBlur"
@keydown="onKeydown">
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
Sorry for the delay, just got round to testing and it works perfectly. Thanks for the quick turn around
awesome thank you!!