Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
Javascript Uncheck all boxes function to Vue

I am trying to figure out how this function would be converted to Vue. I basically want to uncheck all checked boxes on the page.

$("#UncheckAll").click(function(){
$("input[type='checkbox']").prop('checked',false);
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You would create data property and bind it to a checkbox. Then your button would modify the property when pressed.

Something like this:

<button @click='isChecked=false'>Uncheck</button>
<input v-model='isChecked' type='checkbox' />

In your component options:

data() { 
  return {
    isChecked: false
  }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Try something like following snippet:

new Vue({
  el: '#demo',
  data: {
    items: [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: 'three'}],
    selected: []
  },
  computed: {
    toggleAll: {
      get: function () {
        return this.items ? this.selected.length == this.items.length : false;
      },
      set: function (value) {
        const selected = [];
        if (value) this.items.forEach((item) => selected.push(item.id));
        this.selected = selected;
      }
    }
  }
});
<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>
<div id="demo">
  <input type="checkbox" v-model="toggleAll">
  <span align="left">Toogle all</span>
  <li v-for="item in items" :key="item.id">
    <input type="checkbox" v-model="selected" :value="item.id" number>
    <span>{{ item.name }}</span>
  </li>
</div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda