1<div x-data="{ open: false }">
2 <button @click="open = !open">Dropdown</button>
3 <ul
4 x-show="open"
5 @click.away="open = false"
6 >
7 <li><a href="#" @click="$dispatch('dropdown-select', { element: 'one' })">One</a></li>
8 <li><a href="#" @click="$dispatch('dropdown-select', { element: 'two' })">Two</a></li>
9 </ul>
10</div>
11<div x-data="{ selected: '' }" @dropdown-select.window="selected = $event.detail.element">
12 <div x-show="selected === 'one'">One showing</div>
13 <div x-show="selected === 'two'">Two showing</div>
14</div>
15