I am currently developing a laravel project and I am faced with the task of iterating over a resource using the @foreach
blade directive like this:
@foreach($users as $user)
<p @click="toggleClick">{{ $user->name }}</p>
<p v-if="clicked">Lorem ipsum</p>
@endforeach
An issue has arisen with this method. The problem is that if there are five users, the toggleClick
listener will be attached to every paragraph. Therefore, clicking on one user will cause all hidden Lorem Ipsum paragraphs to immediately display for all users. Here is an illustration:
John Doe
Lorem ipsum
Jane Doe (Clicked)
Lorem ipsum
Jimmy Doe
Lorem ipsum
What I desire instead is this:
John Doe
Jane Doe (Clicked)
Lorem ipsum
Jimmy Doe
How can I achieve this desired outcome?