Morph and explicitly maintaining state when initial state unknown #2893
samwillis
started this conversation in
3. Feature Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently implementing something using the Morph plugin, we don't know when "morphing" the Dom containing Alpine components what the initial state was when they were created. So when we receive the html fragment from the server its
x-data
will be different from that initially set, this results in the Alpine component be reinitiated and state lost. If we did know the initialx-data
and it was the same the state is maintained.I would like to propose something like a
x-data-maintain
attribute that can be provided in place ofx-data
, the morph plugin can then watch for this and ensure the current component state is kept. I have implemented this with the lifecycle hooks using the very simple code below, however I think this is probably a useful enough feature that having it as standard and documented would be good:Beta Was this translation helpful? Give feedback.
All reactions