Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Trying to change data inside @click inside v-for

i have a v-for loop as my selection for dialog boxes I want to open

<v-card @click="page.model = true">

page.model is my v-model for a v-dialog

  data() {
    return {
      dialog1: false,
      dialog2: false,
      pages: [
        {
          id: "1",
          model: "dialog1",
        },
        {
          id: "2",
          model: "dialog2",
        },
      ],
    };
  },

howcome @click="page.model = true" doesn't work but @click=dialog1 = true " does? I also tried :@click="page.model = true" and @click="${page.model} = true"

Thank you in advance

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

So we dont see your modal HTML so I presume something like this:

<v-card v-for="page in pages" @click="changePage(page.id)">

<modal v-model="pages[0].isOpen">[CONTAIN OF PAGE 1]</modal>
<modal v-model="pages[1].isOpen">[CONTAIN OF PAGE 2]</modal>
  data() {
    return {
      pages: [
        {
          id: "1",
          model: "dialog1",
          isOpen: false,
        },
        {
          id: "2",
          model: "dialog2",
          isOpen: false,
        },
      ],
    },
  methods: {
    changePage(id) {
      // close all other modal page
      this.pages.each(el => el.isOpen = false);

      // open the good one
      const index = this.pages.findIndex(el => el.id == id);
      this.pages[index].isOpen = true;
    }
  },
about 4 years ago · Juan Pablo Isaza Report

0

I have done something similar. Call a method and pass index of item. In the method you can then access the specific model via index

<v-card @click="updateDialog(index)">

updateDialog(i): {
  this.pages[i].model = true
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!