samedi 11 avril 2020

render button based on checkbox count

I'm trying to disable or enable a button based on checkboxes. if two more are checked the button is no longer disabled. This part works but I'm not sure how to disable the buttons again if I uncheck items.

i'm new to vue but I'm wondering how to find out if each checkbox has been either checked OR unchecked so I can correctly move my counter up or down.

 <li class="listItemsModal" v-for="(student, index) in students">
                                <input v-model="student.exclude" @change="toggleAddButton" id="student.index" type="checkbox" > 
                                

                            </li>  

if the button is clicked we add and check to see if the value is bigger than 2 I need some way to access the checked value to see if checked or not, then go up or down accordingly

 toggleAddButton: function(){
                   console.log(this.studentsAdded)
                   this.studentsAdded ++
                   if(this.studentsAdded >= 2){
                    this.disableAdd = false
                   }else{
                    this.disableAdd = true 
                   }

            }



Aucun commentaire:

Enregistrer un commentaire