'How with alpine to make accordion with only 1 item opened?
In laravel 7 with livewire 1.3 and [email protected] I made an accordion like:
<div class="accordion_wrapper">
@foreach($faqs as $nextFaq)
<div class="accordion_{{ $nextFaq->id }}" x-data="{ is_opened: false }">
<button @click="is_opened= !is_opened">
<div>Question {{ $nextFaq->id }}</div>
</button>
<div class="accordion_content" x-show="is_opened">
{{ $nextFaq->id }} Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
</div>
</div>
@endforeach
</div>
and it works, but how can I make with alpine to have opened only 1 item? If user clicks on some other items, the rest of items must be closed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
