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

194
Views
VueJs3 v-if probléme

I have a problem of v-if, I have this button which makes me open a modal and which executes an addClick function

<button
  type="button"
  class="btn btn-primary m-2 fload-end"
  data-bs-toggle="modal"
  data-bs-target="#exampleModal"
  @click="addClick">

In the modal code, I use an if to display either create or update depending on the DepartmentIDjs variable

<button type="button" @click="createClick()" v-if="DepartmentIdJs ==0" class="btn btn-primary">
  Create
</button>
<button type="button" @click="updateClick()" v-if="DepartmentIdJs !=0" class="btn btn-primary">
  Update
</button>

Code JS

let DepartementIdJs = ref('');

const addClick = () => {
  modalTitle = 'Add Departement',
  DepartementIdJs.value = 0;
  DepartementNameJs.value = "";
  console.log(DepartementIdJs.value)
}

return {
  listDepartements,
  DepartementNameJs,
  DepartementIdJs,
  addClick,
  editClick,
  createClick,
  updateClick
}

the console.log gives me 0 while the modal shows me the Update button Can someone explain to me where I made the mistake.

about 4 years ago · Juan Pablo Isaza
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!