I
I
Igor Bezlepkin2018-08-17 15:08:27
JavaScript
Igor Bezlepkin, 2018-08-17 15:08:27

How to pull the data attribute from a checkbox when it changes in Vue?

Hey! There are two cycles:
around this there is another one, but it doesn't matter...

<div v-for="(item, key2) in subitems.items" v-bind:key="key2" v-bind:class="[item == '' ? 'empty' : '']" class="seats-cell">
  <input type="checkbox" v-bind:id="key + item" v-bind:value="key + item" :data-level="subitems.meta.level" :data-name="subitems.meta.name" :disabled="item == ''" v-model="checkbox">
  <label class="label label-default" v-bind:for="key + item"><span>{{ item }}</span></label>
</div>

<ul>
  <li v-for="(item, key) in checkbox" :key="key">Место {{ item }}</li> - тут item это тупо value чекбокса.
</ul>

But in addition to value, you can also pull out the attributes of the checkbox?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2018-08-17
@Bezlepkin

Add a true-value attribute to the checked, and enter an object with the necessary data into it
and now in checked with the selected checkbox there will be an object and the fields level, name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question