Alpine.js
$event
$event magic can be used to access the native JavaScript event object from an expression in any Alpine component.
<button @click="alert($event.target.getAttribute('message'))" message="Hello World">
Say Hi
</button>
In addition, Alpine also passes the event object to any methods referenced without trailing parenthesis. For example:
<button @click="handleClick">...</button>
<script>
function handleClick(e) {
// Now you can access the event object (e) directly
}
</script>
$refs
$refs is a magic property that can be used to retrieve DOM elements marked with x-ref inside the component. This is useful when you need to manually manipulate DOM elements. It's often used as a more succinct, scoped, alternative to document.querySelector.
$watch
You can "watch" a component property using the $watch magic method. For example:
