<div class="container-body" v-for="index in 10" :key="index">
<div class="container-content"></div>
<div class="container-content">
<input :id="'Row'+index+'-input1'" type="text">
</div>
<div class="container-content">
<input :id="'Row'+index+'-input2'" type="text" class="disabled">
</div>
<div class="container-content">
<div class="custom-control custom-checkbox">
<input :id="'Row'+index+'checkbox'" class="form-check-input" type="checkbox" disabled>
</div>
</div>
<div class="container-content delete">
<img/>
</div>
</div>
I will have 10 input rows using v-for.
I need to achieve:
When user enter number on Row1-input1, Row1-input2 and Row1-checkbox will be enabled. The input enabling should not affect the other 9 rows. Also, when I click on the delete div, it should clear the whole row value.
I’m not sure how to achieve this in Vue. Should I create 10 data variables, and save the value onkeyup, and use it bind with :disabled ? Or are there any Vue methods that can achieve this ?
2
Answers
here is an approach:
I think the best approach would be to create a component for one line, where you can put all the logic for working with one instance. And then create the required number of such components.
Here is an example implementation for your task, if I understood everything correctly: