how to implement v-for checkbox list



  • Hi,
    I need to loop through an array of values in a form to create a checkbox list and submit the selected checkbox value. my code is below :

    <tr v-for="(item,index) in MenuList">
    <label>{{item.menu_name}}
    <q-checkbox v-model=“vchecklist[index]” ></q-checkbox>
    </label>
    </tr>

    this is not working . i select one checkbox but selected another one .

    my form design is attached as image :

    0_1497786237761_form.png


  • Admin

    menuList should be { menu_name: 'blabla label', model: false }

    <tr v-for="(item,index) in MenuList">
       <label>
          {{item.menu_name}}
          <q-checkbox v-model=“item.model”></q-checkbox>
      </label>
    </tr>
    

    This is one option. There are others too. Just don’t bind v-model to a numeric index in an array. Use object instead.



  • @rstoenescu thanks a lot :).


Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.