Is it possible for Vue.js sibling components to communicate with each other in order to update the card view only when a new

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>

Answer №1

display:0 represents the initial value stored in this entry. Whenever you refresh the page, this value is also refreshed. To ensure that you have the most up-to-date value of display after reloading, consider utilizing localStorage or a vuex store. Additionally, it would be beneficial if the value of your display is boolean.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Problem with hyperlinks: next character inadvertently added into the <a> tag in the TinyMCE user interface

I'm facing a challenge and struggling to come up with a solution. It could be due to incorrect setup or oversight on my part, but I suspect it might also be a bug. The issue is with the TinyMce setup applied in a Div (editable). setup: function (edi ...

Activate dropdown menu link when tapped twice on tablet devices

I am trying to implement a dropdown navigation link feature on tablets where the child menu div drops down only on the second click. This functionality already works on iPads, but on Android and Windows tablets, the link is triggered at the same time as th ...

Creating a simulation in THREE.js that incorporates MeshBasicMaterial, with the added feature of being able to

Creating a dungeon crawler game using three.js has been quite the learning experience. Initially, I opted for MeshBasicMaterial to ensure everything was uniformly visible in the dungeon. However, I wanted to experiment with adding bonus lights peeking thro ...

Steps to initiate my selenium-standalone server: Execute the command "selenium-standalone start"

I'm currently facing a challenge while trying to execute a test script in WebDriverIO. After cloning the code from wdio-cucumber-framework, I am unable to get selenium-standalone to start properly. The error message indicates an issue with geckodriv ...

React window resizing actionsWould you like some more information on this

I am attempting to create a resize function that will retrieve the window width and dynamically display it using react. Here is my current code: class Welcome extends React.Component { constructor() { super(); this.state = { ...

Error in Blinking Tooltip when Hovering Skill Bubble (React and d3)

I've encountered a frustrating issue with tooltips on my website - they just won't stop blinking when I hover over the skill bubbles. I tried fixing the tooltips at a certain location, but whenever there's a bubble in that spot and I hover o ...

Images showing Strava heat maps retrieved through API

Check out this amazing heatmap created by Strava! I'm curious about how they were able to achieve this - it seems like they are using the API to request overlay images based on the network tab. I have my own geo data, but I'm wondering how I can ...

Leveraging interpolation in nunjucks and Vue.js

Currently, I am utilizing nunjucks for compiling mustache syntax like this: {{ value }}. Simultaneously, I am using Vue.js which also employs the same syntax for interpolation. The issue arises when nunjucks compiles the interpolation before vue.js has a ...

Complete a submission using an anchor (<a>) tag containing a specified value in ASP.Net MVC by utilizing Html.BeginForm

I am currently using Html.BeginFrom to generate a form tag and submit a request for external login providers. The HttpPost action in Account Controller // // POST: /Account/ExternalLogin [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public Acti ...

Use JavaScript to access the dynamic checkboxes in an ASP table by utilizing the functions checkall, uncheck, and middlestate

Currently, I am working on creating a privilege group checkbox similar to the one shown in this link. On my page, I have created an empty control that looks like this: <fieldset> <legend><asp:CheckBox ID="GroupName" runat="server" TextAl ...

Tips for creating a unique scroll page arrow button with adjustable thickness?

Seeking guidance on how to adjust the thickness of the arrow used as a scroll button on my website. I am aiming for a similar look to the arrow on this particular website: example of arrow https://i.sstatic.net/wO5br.png To view my code, please visit: Cod ...

Looking to utilize a for loop in Weex? You can achieve this by implementing a loop similar to the following example: for (let i = 0; i < n; i++){} . This can be useful in instances where you

Consider this scenario: I need to display a box multiple times. How can I create a for loop in Weex template to render the box n number of times? <template> <div> <div class="box" ></div> <div class="box" ></d ...

What is the most effective way to receive all values sent to an Observer upon a new subscription?

I have an observer that receives various values emitted to it at different times. For instance sub = new Subject<any>(); sub.next(1); sub.next(2); sub.next(3); #hack 1 sub.next(4); sub.next(5); sub.next(6); #hack 2 If there is a ...

Oops! There seems to be an issue with the table component in the project. The error is coming from the babel-loader and vue-loader while trying to load the script for the table.vue file. Let

Encountering an issue when loading Vue components from the same folder in Vue.js. The import seems to be done correctly, but during the build process, the following error is displayed. ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/l ...

Update the default selection for all the VueJS Multiselect options

I am currently utilizing the vue-multiselect.js library (available at ). Currently, I am in need of translating all text to German. Right now, I am achieving this by using custom settings within the multiselect. <multiselect id="account-selected&q ...

What steps can I take to avoid Cumulative Layout Shifts when deploying a Vue3 application?

My understanding is that Vue3 relocates the content of the mounted element to the virtual DOM. However, this results in the content momentarily disappearing and then reappearing when the app mounts, leading to noticeable Cumulative Layout Shift. Although ...

What is a method to pull out numerical values from a text in JavaScript without the use of regular expressions?

Consider this scenario: I have a string "asdf123d6lkj006m90" and I want to extract the values [123, 6, 0, 0, 6, 90]. My attempt so far is as follows: let str = "asdf123d6lkj006m90" let func = function(inputString){ let outputArray = [] le ...

Running multiple nodemon inspect programs concurrently is not supported

Situation: currently operating Ubuntu 19.10 on an Inspiron 560. I am managing 2 distinct Discord bots that need to be active on the same device (my other spare machines are currently occupied with other tasks and lack the capacity to handle Discord bots). ...

The call stack size has reached its maximum limit due to running 2 Collection.find commands

I've encountered a Maximum call stack size exceeded exception in my Chrome console while working with Angular2 and Meteor. This issue started after I added the following code to my client side: var userChannelsId = UserChannels.find({idUser: Meteor.u ...

The value of msg.member is empty following the messageReactionAdd event

Whenever someone reacts on my server, it triggers the messageReactionAdd event. However, I am encountering difficulty in retrieving the member object of the author of a message that someone reacted to: module.exports = async (client, messageReaction, user) ...