nanadjei2
1 year ago
1043
4
Vue

Add id from v-for to dom elements

Posted 1 year ago by nanadjei2

I am making a for loop with vuejs and displaying a list of users in a table. I want to add the id of users to the action attribute of a form element or classes of the elements in the table items.

This is my html:

    <tr v-for="(user, key, index) in users">
         <td>@{{ key+1 }}</td>
         <td v-text="user.name"></td>
         <td>@{{ user.email }}</td>
         <td>@{{ user.status }}</td>
          <td>
       <div class="btn-group pull-rights" role="group" aria-label="action-btns">
    <form id="statusform" :action="baseUrl+/user.id" method="POST">
    <label class="ui-switch mt-1 mr-2">
      <input @click="onSwitchStatus(user.id)" type="checkbox" :checked="user.status == 'active'" :value="user.status">    
        </form>
    </div>
   </td>

Am using laravel. I want the action attribute of the form to be for example… ‘localhost/project/user/edit/1/’ but it is not working. Can anyone help me;

Please sign in or create an account to participate in this conversation.