Skip to content

Commit

Permalink
Update refs.md (#3851)
Browse files Browse the repository at this point in the history
* Update refs.md

Added details on $refs not supporting dynamic binding anymore in V3

* Update refs.md

Fixed logic of the example to reflect the actual evaluation of $refs
  • Loading branch information
Simsz committed Dec 15, 2023
1 parent 0115f8b commit b24d8be
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/docs/src/en/magics/refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ title: refs
<!-- END_VERBATIM -->

Now, when the `<button>` is pressed, the `<span>` will be removed.

<a name="limitations"></a>
### Limitations

In V2 it was possible to bind `$refs` to elements dynamically, like seen below:

```alpine
<template x-for="item in items" :key="item.id" >
<div :x-ref="item.name">
some content ...
</div>
</template>
```

However, in V3, `$refs` can only be accessed for elements that are created statically. So for the example above: if you were expecting the value of `item.name` inside of `$refs` to be something like *Batteries*, you should be aware that `$refs` will actually contain the literal string `'item.name'` and not *Batteries*.

0 comments on commit b24d8be

Please sign in to comment.