How to bind data to an already data-bound element in Vue 2

To view a JS Fiddle example of this concept, click the link below:

JS Fiddle Demo

Essentially, I have three text areas. The content entered in the first text area should automatically appear in the second text area, which will then be copied to the third text area as well.

<div id="app">
<textarea v-model="first"></textarea>

<textarea v-model="second">{{first}}</textarea>
 <textarea>{{ second }}</textarea>

Answer №1

To capture any modifications in the value of first and transfer it to second and then to third, you can utilize the watch properties:

new Vue({
  el: '#app',
  data: {
    first: '',
    second: '',
    third:''
  },
  watch:{
     first(val){
     this.second=val;
     },
        second(val){
     this.third=val;
     }
  }
})
<script src="https://unpkg.com/vue"></script>

<div id="app">
<textarea v-model="first"></textarea>


<textarea v-model="second" ></textarea>
  <p>2 >> {{ second }}</p>
  <textarea v-model="third" ></textarea>
   <p>3 >> {{ third }}</p>
</div>

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

Avoiding the repetition of a specific item in a Vuetify card

Is there anyone who can assist me? I am trying to display the card-title only in card-1. I do not want the card-title to be shown in card-2, card-3, and card-4. <v-app> <v-row v-for="(item, index) in list" :key="index"> ...

Is Angular capable of displaying a date within a specific timeframe using ng-show?

So I have a button that, when clicked, displays a list of data. I am adding a unique font awesome icon in there if the JSON key value exists. However, here lies the issue. The particular key happens to be a date. I need my ng-show function to check whether ...

In three.js, it is important to understand that Vertex and Vector3 are not simply

When I started using three.js revision 48, I created vertices connected by lines without any issues. However, upon updating to revision 65 from 48, an error message appeared stating that Vertix is deprecated and should be replaced by Vector3. Unfortunately ...

The x-axis is fixed and displays a datetime type column

My chart's column type is set to datetime but it is displaying unnecessary dates with large spaces in between on the x-axis, and the size of the columns has been reduced to almost invisible. [screen shot 1]: https://i.sstatic.net/oXpUT.png If I cha ...

Table sorting feature with checkboxes has disappeared from view

This segment of code includes HTML for a table along with JavaScript functionality. When a checkbox is clicked, another table will be displayed: <form class="filter"> <input type="checkbox" id="checkboxID" class="unchecked"> EG <input type= ...

Seeking assistance in the development of a visual depiction of device orientation through JS

My goal is to visually represent the device orientation values alpha, beta, and gamma by creating a series of "bars" for each value. Currently, I have managed to display only the values in plain text using innerHTML. However, I envision these bars moving i ...

What are the steps to effectively utilize the static folder in Django for organizing CSS and JavaScript files?

I'm completely new to the Django framework. I managed to create a simple welcome page, but now I'm struggling to include a CSS file in my project. Whenever I try to apply the CSS file, I encounter an error saying "NetworkError: 404 NOT FOUND - / ...

Why is the child's CSS hover not functioning when the body has an event listener attached to it?

Check out the repository link here: https://codepen.io/Jaycethanks/pen/WNJqdWB I am trying to achieve a parallax effect on the body and image container, as well as a scale-up effect on images when hovered over. However, the hover functionality is not work ...

Sorting by two fields with varying value types in AngularJS

Need help sorting json data by two fields, prioritizing field value and then date. Check out this demo Json input [{ "title" : "Title 2", "pin" : false, "date" : 20130411204207 },{ "title" : "Title 3", "date" : 20140411204207 },{ "title" : "Title 4", ...

The jQuery code does not execute following the use of window.location.replace( url ) command

I'm facing an issue with my code that involves redirecting the page to the index page after clicking on a specific link ('#versionPageFromProdLink'). The index page contains certain content within a div, which I want to hide once the redirec ...

jquery event not triggering

I have a list that loads items when the page loads, and when I click a checkbox on the page, it loads items with json. $('.content-items:checkbox').on('change', function () { $.get(newUrl, function (data) { $("#ProductsPar ...

Utilize jQuery to extract data from a JSON string

Trying to decode a JSON string containing multiple arrays and key:value pairs. Successfully retrieving information from one array, but struggling to access data from a different array with the same keys. The jQuery code snippet in question: $("a").click( ...

Utilizing JQuery to request a file input and subsequently handle its processing

I am working towards creating a functionality where users can click a button, select a file, and have the program perform actions on that file, such as sending it through an AJAX request for processing. Currently, I have set up a hidden form along with a b ...

Unveiling Fresh URLs within an iFrame

Here is the current situation: www.mywebsite.com/Pagex.html - On this page, there is an iFrame with a default URL (src) from a different domain than the host page (Pagex.html). The code inside the iFrame is a user input form with a submit button. Upon su ...

How can you retrieve the component's state from a higher level without relying on useContext?

I have a question regarding creating expanding flex cards. I found an example on Codepen that showcases what I'd like to achieve: https://codepen.io/z-/pen/OBPJKK In my code, I have a component called HomeButtons that generates these flex cards. With ...

Enforcing automatic spell check on dynamically generated content

After some experimentation, I have discovered that the spell check feature in most browsers is only activated when the user moves to the next word after inputting text. Another interesting finding is that it is possible to "query" the spellchecker by simpl ...

Charting with multiple series

I am exploring a unique approach to creating a timeline chart. I am seeking advice on the best way to implement this in the world of JavaScript. My challenge is to create interactive milestones with descriptive text displayed on the Y axis, while displayi ...

Transferring data from AJAX to PHP

I am currently developing a project in PHP. I have created an associative array that functions as a dictionary. Additionally, I have a string containing text with placeholders for keys from the array. My goal is to generate a new String where these key wor ...

Dynamic Management of Watchers in Vue.js

I'm facing an issue with a component that has a table row containing multiple fields. When I update one field, it triggers changes in another field based on margin or sell price. However, monitoring all the fields results in a bouncing effect. Adding ...

Express.js code is experiencing difficulties with autocomplete functionalities

jQuery autocomplete code example [Express JS code for retrieving data][2\ Example of fetching data in Express JS ...