Replies: 4 comments 2 replies
-
Based on this code, this would be expected behavior. You're only doing one way binding on events, so on refresh the component does not have the state of the selected radio element, even though the browser preserves it. The radio doesn't emit a change event on load. You can use x init on the rwidos to persist the correct value, or use x-model instead, ideally x-model.fill which would handle this easily :) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the detailed response! I tried using |
Beta Was this translation helpful? Give feedback.
-
the alpine docs example doesn't account for page reloads either. |
Beta Was this translation helpful? Give feedback.
-
in the examples that i've seen that look like they would work, the whole list is defined in the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
hi,
I have something like:
This correctly renders the appropriate x-if template based on the radio group's checked value, and when i refresh the page, the radio input/value remains checked, but the corresponding x-if template is not automatically re-rendered.
While unexpected to me, maybe this is expected behavior for alpine? It seems like maybe i'm supposed to pull in the
persist plugin
to persist the value/checked state to session and perhaps use a unique id to avoid conflicts. Is that really necessary just to have it re-render the x-if template based on the current value of the radio? It seems like i should be able to have something besides a empty string for the default value oflayout_preset
in thex-data
tag, instead of persisting to localStorage or session, but so far i haven't got anything to work. I just want to make sure i'm not missing something basic.thanks
Beta Was this translation helpful? Give feedback.
All reactions