Skip to content
Discussion options

You must be logged in to vote

I wouldn't use x-ref.
X-ref usually means that you are trying to apply imperative code to Alpine which tends to be declarative (you don't change objects, you change a state and let all objects react to it). You can use something like

<template x-for="i in 10">
    <div x-data="{open: false}">
      <details x-effect="$el.open = open">
        <summary x-text="i"></summary>
      </details>
      <button x-on:click="open = !open" x-text="`open ${i}`"></button>
    </div>
</template>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jimmywarting
Comment options

Answer selected by jimmywarting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants