# Alpine.js Documentation - Magics Magics are special properties that are available inside Alpine expressions. They provide convenient access to common functionality. ## [$dispatch](/magics/dispatch) `$dispatch` is a helpful shortcut for dispatching browser events. ```
n n
``` You can also pass data along with the dispatched event if you wish. This data will be accessible as the `.detail` property of the event: ```
n n
``` Under the hood, `$dispatch` is a wrapper for the more verbose API: `element.dispatchEvent(new CustomEvent(...))` **Note on event propagation** Notice that, because of [event bubbling](https://en.wikipedia.org/wiki/Event_bubbling), when you need to capture events dispatched from nodes that are under the same nesting hierarchy, you'll need to use the [`.window`](https://github.com/alpinejs/alpine#x-on) modifier: **Example:** ``` n
n n n
n n
n n n
``` > The first example won't work because when `notify` is dispatched, it'll propagate to its common ancestor, the `div`, not its sibling, the ``. The second example will work because the sibling is listening for `notify` at the `window` level, which the custom event will eventually bubble up to. ### [Dispatching to other components](#dispatching-to-components) You can also take advantage of the previous technique to make your components talk to each other: **Example:** ```
nh1 x-text="title"> n
n
n n
n ``` ### [Dispatching to x-model](#dispatching-to-x-model) You can also use `$dispatch()` to trigger data updates for `x-model` data bindings. For example: ```
n n n n n
``` This opens up the door for making custom input components whose value can be set via `x-model`. Code highlighting provided by [Torchlight](https://torchlight.dev/)