Blur event not supported
See original GitHub issueIt would be really awesome to add some of the native browser events to the input, for example Im trying to tie Vuelidate in with the @blur event.
I might make a pull request for this, but the simplest solution I can think of is to add:
@blur="emit('blur')
to the input. This could also be the case for any other native events you want to support.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:11
Top Results From Across the Web
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >Javascript function not working on blur event - Stack Overflow
I have written a function which I expect should check if a text field is empty and if so should bring the focus...
Read more >On Blur event not supported · Issue #44 · tinymce ... - GitHub
I would like capture the content only after user completes the edit operation. so please add the onBlur event support.
Read more >.blur() | jQuery API Documentation
The blur event does not bubble in Internet Explorer. Therefore, scripts that rely on event delegation with the blur event will not work...
Read more >Blur Event not working on windows? | Velo by Wix
Blur Event not working on windows? ... Hi everyone,. I have created an onBlur event for many text boxes that triggers a save...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is very fascinating. I was able to reproduce that by installing a
v-if
on my wrapper component. The issue is thatv-if
removes the datepicker input element from the DOM, and then the Vue instance is destroyed after, which meansbeforeDestroy
is called after the DOM element has already been removed.I have a new solution now which is simpler (and should be closer to an “Occam’s Razor” solution). It uses event delegation and relies on the
focus
andblur
events bubbling up the DOM tree into your wrapper component.Try this instead:
markup:
note: We are not using the
id
prop anymore. We simply placefocusin
andfocusout
events on the wrapper for the datepicker. In my testing here, it does not work if you place them on the<datepicker>
. It must be on the parent.instance methods:
I also learned along my way that memory leaks are fine in modern browsers because when DOM elements are removed, their event listeners are garbage collected. This is only an issue in IE7 which Vue does not support. So technically, you could delete the
beforeDestroy
lifecycle method and never run into any trouble, but I personally am not a fan of that. I prefer the event delegation solution due to its minimal surface area.Here is a work-around I’ve been using:
…
If you are not using the
name
prop, note that multiple date pickers on the page with the same ID will be problematic for `getElementById.