Skip to content
Discussion options

You must be logged in to vote
<div id="root" x-data="{ active: null }" x-init="console.log('Root initialized:', $el)">
<div>
    <div>
        <div id="notRoot" x-data="{
                id: 1,
                get expanded() {
                    return this.active === this.id;
                },
                set expanded(value) {
                    this.active = value ? this.id : null;
                }
            }">
            <button x-on:click="expanded = !expanded" :aria-expanded="expanded">
                Button
            </button>
        </div>
    </div>
    <div x-show="active === 1" x-collapse>
        hello world
    </div>
</div>

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@AlexanderBoenninger
Comment options

@SimoTod
Comment options

SimoTod Apr 17, 2025
Collaborator

Answer selected by AlexanderBoenninger
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants