How can I change x-data after a component is rendered? #572
ragjunk
started this conversation in
4. General
Replies: 2 comments 4 replies
-
|
You can use any variable on the E.g. <div x-data="{sortOrder: 'asc'}">
<button x-on:click.prevent="sortOrder = sortOrder === 'asc' ? 'desc' : 'asc'">Toggle sort order</button>
</div> |
Beta Was this translation helpful? Give feedback.
4 replies
-
|
https://github.com/alpinejs/alpine/blob/master/README.md#x-on |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have components that initialize with x-data (and x-init in some cases), but the "data" can change based on user interaction. For example, sorting a table based on the sort order selected. I didn't find any examples or documentation on how the data can be changed after a component has rendered. Is there a way to "set" the data to force re-rendering of the component?
Beta Was this translation helpful? Give feedback.
All reactions