Preserving client side state, specifically details
#1004
-
Hi - how should I go about preserving client side state between updates. Specifically whether a I can POST the data to the server but the Is there a more Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hi @yatesco , have you tried hx-preserve ? |
Beta Was this translation helpful? Give feedback.
-
Thanks David, yes I looked at that, but I do actually want to replace the ‘details’ element.
…Sent from my iPhone
On 12 Aug 2022, at 21:38, David Guillot ***@***.***> wrote:
Hi @yatesco , have you tried hx-preserve ?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
Ah yes... In this case it's a bit trickier. I have one more idea for you, but I haven't tested it. It would be to combine hx-preserve and hx-swap-oob to:
On server side, you'd have to:
I hope this is clear enough... |
Beta Was this translation helpful? Give feedback.
-
I had a similar problem, my first solution was just as @yatesco described, but I later found it unnecessary complex. I stopped using the details and used my own custom element. The details contents will be inside this element as well, but I created also an adicional element to hold the collapsed state. This element is the one tagged with |
Beta Was this translation helpful? Give feedback.
-
I ended up here after searching for "hx-preserve not working properly with oob" on Kagi, and I can't seem to make this work in 2.0.2. I think the bug described below is affecting this: In short, |
Beta Was this translation helpful? Give feedback.
Ah yes... In this case it's a bit trickier. I have one more idea for you, but I haven't tested it. It would be to combine hx-preserve and hx-swap-oob to:
<details>
, in order to preserve its stateOn server side, you'd have to:
<div>
which would hold the id that's required forhx-swap-oob
I hope this is clear enough...