Say, I am showing some posts that I got from an ajax response. Now I want to add the option to edit any particular post on clicking some button. I guess, I could do it using v-show, where I will attach a form component or something with every single post and when the user clicks the edit button I will hide the post div and show the form with post's body and title and again on clicking save I could hide the form, send a request to the server to update the post then show it again.
Now my question is, is it doable without attaching and hiding anything in the first place? Because, how many times will I get users wanting to edit their posts? I want to call a function or something else with the post on some button click which will return a component with one or two text fields that have post data as their value.
Is it even possible using Vue?
html
which would be present in theDOM
percomment-component
if you addedit-comment-component
? also without usingv-show
. isv-if
off the list too? because that would do the trick. – Amresh Venugopalv-show
orv-if
, I just do not want to attach and then hide thatedit-comment-component
. On some event, I do want to hide the post but loadedit-comment-component
rather making it visible by changing some boolean variable. – Foolish and Hungryv-if
v-show
would help you in maintaining theedit-comment-component
in the document flow. Dynamically creating a component can work out too, but now that you say 'load' do you mean async loading the component? – Amresh Venugopal