x-show not working when condition variable is saved persistent #3693
Replies: 7 comments 7 replies
-
|
PS: I need to change the template notation in this case to x-show in order to avoid content shifts on the initial page load (for most cases). |
Beta Was this translation helpful? Give feedback.
-
|
Can you show more code for context? |
Beta Was this translation helpful? Give feedback.
-
|
Sure, here is the full context: https://rc.swisswebcams.ch/_new/index.html
Am Fr., 4. Aug. 2023 um 05:49 Uhr schrieb Eric Kwoka <
***@***.***>:
… Can you show more code for context?
—
Reply to this email directly, view it on GitHub
<#3693 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAK6SOYBM2YFLJWEAHL7XOTXTRWLVANCNFSM6AAAAAA3DIIG7M>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
To be more specific, on view-source:
https://rc.swisswebcams.ch/_new/index.html at line 172
<section class="intro roundshot" :class="!visible.intro && 'paused'" :style
="`background-image: url(${bg})`" x-bind="$intro" x-data="{ bg: '', pause:
false }" *x-show="(view !== 'map') && content.roundshot**"*>
Am Fr., 4. Aug. 2023 um 12:45 Uhr schrieb Simon Ferndriger <
***@***.***>:
… Sure, here is the full context: https://rc.swisswebcams.ch/_new/index.html
Am Fr., 4. Aug. 2023 um 05:49 Uhr schrieb Eric Kwoka <
***@***.***>:
> Can you show more code for context?
>
> —
> Reply to this email directly, view it on GitHub
> <#3693 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAK6SOYBM2YFLJWEAHL7XOTXTRWLVANCNFSM6AAAAAA3DIIG7M>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
|
The only workaround so far to make it work with
|
Beta Was this translation helpful? Give feedback.
-
|
@ekwoka |
Beta Was this translation helpful? Give feedback.
-
|
Glad I found this post. When building cookie banners, I usually store a const page = function() {
return {
cookies: this.$persist({
consent: false,
closed: false,
types: [
{
type: "necessary",
selected: true,
default: true,
},
{
type: "youtube",
selected: false,
default: false,
},
// other cookie types here
]
}).using(cookieStorage),
}
};
export default page;That component is placed on the body of each document. I then have a const cookieBanner = () => {
return {
showBanner: true,
show() {
this.showBanner = true;
},
hide() {
this.showBanner = false;
this.cookies.closed = true;
},
save() {
this.cookies.consent = true;
this.hide();
},
init() {
if (this.cookies.closed) {
this.hide();
} else {
this.show();
}
}
}
};
export default cookieBanner;So when using the save button in the modal, it should change the It doesn’t hide. I tried debugging it with
When I use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a section with the following condition
x-show="view !== 'map'"whileviewis defined asAlpine.$persist(config.defaultView). Now, when the default view changes, it appears correctly when logged out, but the section still shows (i.e. initially seems to use the initial defaultView instead of the stored view.The funny thing is, when I use the exact same condition for
<template x-if="...">it actually works correct!Beta Was this translation helpful? Give feedback.
All reactions