I have some autocomplete thingy in vuejs. When you start typing you get a list and if you click on some element that has some function bind to it, that function is never executed because of blur. But keep in mind that someone maybe clicked outside without selecting anything (list should be closed).
I have made jsfiddle with example: https://jsfiddle.net/4m47bbh3/1/
new Vue({
el: "#app",
data:{
open: false,
letter: ""
},
methods: {
set_data(letter) {
this.letter = letter
},
_close(){
this.open = false;
//i can add here setTimeOut function but i dont know how many miliseconds/seconds blur will be pressed
//someone can hold it for 10 - 20 just to proof that you cna not relay on setTimeout
},
_show(){
this.open = true;
}
}
})
<div id="app">
<input v-on:blur="_close" v-on:keyup="_show"/>
<ul v-if="open">
<li v-on:click="set_data('A')">A</li>
<li v-on:click="set_data('B')">B</li>
<li v-on:click="set_data('C')">C</li>
</ul>
<div>
{{letter}}
<!-- this letter will be always empty -->
</div>
</div>
As i commented in example i can do setTimeOut but that will just not work since i dont know for how many miliseconds/seconds blur will last.