Whenever I click on the "insert text" button within component B, it adds a text card from component A. The issue arises when inserting the card - I need the textarea and save button to be visible, but once saved, the textarea should hide. This functionality works correctly; however, upon page reload, the textarea and save button reappear. Note that components A and B are siblings.
//Component A
<template>
<div class="answer-text-container answer-inner-container">
<div class="content-inner">
<p class="answer-type">{{ text.type }}</p>
<p v-show="!this.show" class="answer-text">{{ text.body }}</p>
<textarea v-model="text.body" v-show="this.show" rows="3" class="edit-text-area border rounded" placeholder="Enter the text here"></textarea>
</div>
<div class="button-container" v-show="!this.show">
<button type="button" @click="editText" class="btn btn-primary edit-text-btn">
<i v-bind:class="[editTextString]"></i>
</button>
<button type="button" @click="$emit('delete')" class="btn btn-danger edit-text-btn">
<i class="fas fa-trash-alt"></i>
</button>
</div>
<button type="button" @click="editText" class="btn btn-success rounded" v-show="this.show">Save</button>
</div>
</template>
<script>
export default {
data: function() {
return {
show: 0,
editTextString: "far fa-edit"
};
},
props: ["text"],
methods: {
editText() {
this.show = !this.show;
console.log(this.text);
},
removeTextComp() {}
}
};
//component B
<template>
<div class="toolbar-container mb-4">
<div class="col-md-12 p-0 text-center">
<div class="row mx-0">
<div class="col-md-4 p-0 d-inline-block toolbar-sub-container">
<a @click="insertText" href="#">
<p>Insert Text</p>
</a>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data: function() {
return {};
},
mounted() {},
methods: {
insertText() {
this.$parent.insertTextComp();
}
}
};
</script>