Replies: 2 comments
-
As I wrote in a previous thread, the persist attribute is meant for single elements to maintain their internal state in JS. It's not an alternative to using containers. So using it the way you're doing, I'd suspect it to break in subtle ways that would be hard to debug. Why not switch to using containers only? You can still set them dynamically depending on whatever conditions you're checking against. |
Beta Was this translation helpful? Give feedback.
-
To answer your question more directly, though, there's currently no feature in swup to globally disable persisting elements. But you could probably remember which elements had the attribute before the content update (maybe in |
Beta Was this translation helpful? Give feedback.
-
In some cases I need all
data-swup-persist
to be ignored, for example "language switch".For this, I wrote some coding using hooks and tried to show them as separate containers. You can find the code I made below:
This way it adds the container properly as
[data-swup-persist="unique-key"]
, but it cannot "Override" it.Is there another way to do this?
I have experienced that if I remove the
[data-swup-persist]
attribute it works. But I am not sure how accurate this approach is. Because theoretically if the response is before these removals it will not work. Do you think this approach is accurate enough?Beta Was this translation helpful? Give feedback.
All reactions