V
V
vism2017-10-17 21:23:34
Vue.js
vism, 2017-10-17 21:23:34

How to get v-for list item in VueJs?

On a very old project, I use vue in conjunction with jquery.
When adding dynamic elements through v-for, you need to bind jquery only to the elements of this block.
In my example, the datepicker is rebinded on the entire page, to the rendered block.

addNewTemplate() {
    let newTemplate = this.bankingTemplates[this.selectedNewTemplate];
    newTemplate.entry_date = moment().format('DD.MM.YYYY');
    newTemplate.invoice_date = moment().format('DD.MM.YYYY');
    if (newTemplate) {
        this.rows.push(newTemplate);
    }
    this.$nextTick(function () {
        $(".datepicker").datepicker();
    });
},


As I understand it, it's better to wrap each datepicker in a component.
But I want to bind only to this new block, for a better understanding of vue.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-18
@vism

You can try to remember when adding the index of a new element and use it when creating a datepicker. Somehow so .
And of course you're right - it's better to make a component. For example, so .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question