Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

newbie360's avatar

Alpine.js any magic method can reset $persist to init value?

<div
    x-data="{
        tableColumnsVisibility: $persist([true, false, true]).as('local-storage-name'),
    
        tableColumnsVisibilityToDefault() {
            this.tableColumnsVisibility = [true, false, true];
        },
    }"
>
    ...
</div>

as you can see i need to render [true, false, true] twice, just want to know any builtin magic method can reset the variable tableColumnsVisibility to init value?

0 likes
4 replies

Please or to participate in this conversation.