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

170
Views
Vue 3 unchecking custom checkbox component

Hey guys I have the following problem: I want to uncheck the custom checkbox components after I submit the form. I set the v-model to an empty object after submitting (account.value = {}) but the box still stays checked even though the value is empty.

Child Checkbox.vue:

<template>
  <div class="checkboxContainer">
    <label :for="id">{{ text }}</label>
    <input
      :id="id"
      type="checkbox"
      @change="$emit('update:modelValue', $event.target.checked)"
    />
  </div>
</template>

<script setup>
import { defineProps } from 'vue'

defineProps({
  text: {
    default: '',
    type: String
  },
  id: {
    default: '',
    type: String
  }
})
</script>

Parent.vue:

<template>
  <form @submit.prevent>
    <div class="formWrapper">
      <Checkbox
        id="changeEmail"
        v-model="account.changeEmail"
        text="Can Change Email: "
      />
      <Checkbox
        id="changeUser"
        v-model="account.changeUser"
        text="Can Change User: "
      />
      <button type="submit" @click="createAccount()">Create</button>
    </div>
  </form>
</template>

<script setup>
import { ref } from 'vue'
import Checkbox from '@/components/helpers/Checkbox.vue'
import axios from 'axios'

const account = ref({})

const createAccount = () => {
  axios
    .post('/api/account-management/accounts', {
      can_change_own_email: account.value.changeEmail,
      can_change_own_user: account.value.changeUser
    })
    .then(() => {
      account.value = {}
    })
}
</script>

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!