Added
$dispatch
magic function for dispatchingnew CustomEvent
s easily:
<div x-data="{ foo: 'bar' }" x-on:custom-event="foo = $event.detail.newValue">
<span x-text="foo"></span>
<button x-on:click="$dispatch('custom-event', {newValue: 'baz'})">Turn 'bar' to 'baz'</button>
</div>