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

91
Visualizações
State changed before displaying swal message in vuejs
<b-card-text class="mb-0">
    Success
</b-card-text>
<b-form-checkbox
   checked="true"
   class="custom-control-success"
   name="check-button"
   switch
   @change="changeStatus"
/>

    changeStatus() {
      this.$swal({
        icon: "question",
        text: "Change Status?",
        buttonsStyling: false,
        showCancelButton: true,
        confirmButtonText: "OK",
      }).then((result) => {
        if (result.isConfirmed) {
          // handle code
        }
      });
    },

I am making checkbox in vuejs. When I click on the status to switch the status, it shows a swal saying Change Status. The problem I have is: When I just press status, a message swal appears, the status has been changed. I want if I press Ok the status will change, but if I press cancel it will stay the same, Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

your switch is not reactive value
checked default is true right, when its change it will be false

you just need make it reactive

example:
data():{ arr:[{name: "test", status: true}, {name: "test2", status: false}]}

make it reactive

<table id="example-1">
  <tr v-for="item in arr" :key="item.name">
    <td>{{ item.name }}</td>
    <td>
    <b-form-checkbox
       checked="item.status" <--- this make it reactive
       class="custom-control-success"
       name="check-button"
       switch
       @change="changeStatus"
    />
  </td>
  </tr>
</table>
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