Discussion icon indicating copy to clipboard operation
Discussion copied to clipboard

Does Vuejs support blur events?

Open jakeryansmith opened this issue 9 years ago • 14 comments

Just wondering if v-on="blur: someFunction" should work? It doesn't seem to be registering the event listener. Thanks!

jakeryansmith avatar Jul 21 '15 22:07 jakeryansmith

Ye it works just fine. Just click on the button and then click somewhere else to trigger the blur event.

http://jsfiddle.net/hajkrupo/4/

swift1 avatar Jul 21 '15 22:07 swift1

Ahh I see what I was doing wrong now. I was declaring each event listener separately (with multiple instances of 'v-on') instead of putting them all under one and separated by a comma, like you have in your example. Silly mistake. Thank you for your help!

jakeryansmith avatar Jul 23 '15 02:07 jakeryansmith

@swift1 Hm, your fiddle seems to be broken atm:

vue.js:1023 [Vue warn]: Invalid expression. Generated function body:  scope.click:scope.increaseTotal, blur:scope.onBlur

So, what is a way to use blur event now?

se-panfilov avatar Jun 27 '16 11:06 se-panfilov

The fiddle uses pre-1.0 syntax, but the config points to the latest vue versionl, therefore it's completely broken in its current form.

This is valid 1.0 syntax: https://jsfiddle.net/hajkrupo/25/

LinusBorg avatar Jun 27 '16 11:06 LinusBorg

For future questions, please visit forum.vuejs.org

LinusBorg avatar Jun 27 '16 11:06 LinusBorg

You can use in vue v2 @blur="some-method-here"

ronaldotn avatar Jan 07 '17 10:01 ronaldotn

This worked for me.

<input v-on:blur="myFunctionHere()" />

thedanotto avatar Jan 15 '17 22:01 thedanotto

@blur works for me with Vue 2.3.2.

oskarrough avatar May 04 '17 10:05 oskarrough

v-on:blu or @blur works for me with Vue 2.3.2

LennonSantos avatar Jun 13 '17 17:06 LennonSantos

blur and click can't be trigger together. <input @blur="function_A"> <button @click="function_B"> if focus into input element first and then click button, will only trigger the function_A, but function_B never been triggered. any body know why?

TrendAlan avatar Jul 05 '17 06:07 TrendAlan

@blur works fine for me, thanks @ronaldotn

noprom avatar Jul 19 '17 01:07 noprom

Guys, can you please move to forum or chat?

nickmessing avatar Jul 19 '17 02:07 nickmessing

@TrendAlan I think your answer to your question is here: https://github.com/vuejs/vue/issues/3350

shaunc869 avatar Oct 11 '17 14:10 shaunc869

@shaunc869 , thank you. My question is the same with that link, I also used mousedown instead of click, since the button will be hidden when the blur event is triggered, so it can't be clickable any more.

TrendAlan avatar Oct 12 '17 01:10 TrendAlan