I'd like to turn a div
into input box on click, so that the post (which is rendered inside a loop) can be edited.
Here is the button on the post:
<a @click="setFocusEdit(index)" v-if="isAuthor(post)" href="#" >Edit Me</a>
And the div
concerned:
<div :ref="'p' + index" class="post-description">
{{post.description}}
</div>
The method:
setFocusEdit(index) {
console.log('focusing on', index);
this.$refs['p' + index].focus();
},
But I get this error:
Uncaught TypeError: this.$refs[("p" + index)].focus is not a function
How can I fix this?
index
is notundefined
, right? – Jovitajovitah