I am in search of a Vue component that allows for click-and-edit functionality.
After discovering this fiddle, I made some modifications. It functions like this:
https://i.sstatic.net/bSMPj.gif
The issue: Currently, an additional click is required to focus on the input field. How can I achieve automatic focus?
The HTML code snippet from the fiddle:
<div id="app">
Click the values to edit!
<ul class="todo-list">
<li v-for = "todo in todos">
<input v-if = "todo.edit" v-model = "todo.title"
@blur= "todo.edit = false; $emit('update')"
@keyup.enter = "todo.edit=false; $emit('update')">
<div v-else>
<label @click = "todo.edit = true;"> {{todo.title}} </label>
</div>
</li>
</ul>
</div>
JavaScript (JS) portion:
new Vue({
el: '#app',
data: {
todos: [{'title':'one value','edit':false},
{'title':'one value','edit':false},
{'title':'otro titulo','edit':false}],
editedTodo: null,
message: 'Hello Vue.js!'
},
methods: {
editTodo: function(todo) {
this.editedTodo = todo;
},
}
})