[Vuejs]-List of checkboxes wont update in dynamic generated array of checkboxes v-models

0👍

After a few days looking at the problem in reactivity, the fix was the following:

Changed this

role_permissions: {}

To this:

role_permissions: []

Then the critical part of why this was not working, was in the initialization of the array. This happens in getPermissions() and this is what I did:

Changed this:

for(var i = 0; i < this.permissions.length; i++){
   this.role_permissions[this.permissions[i].name] = this.hasPerm(this.permissions[i].name);
}   

To this:

for(var i = 0; i < this.permissions.length; i++){
   this.$set(this.role_permissions, this.permissions[i].name, this.hasPerm(this.permissions[i].name));
}

Instead of using "=" use "$set" for value assignment.

-1👍

You use v-model and bind:value at the same time in your switch tag

👤ElTs

Leave a comment