Skip to content
Discussion options

You must be logged in to vote

You can't have dynamic ref in Alpine v3. See #1527 (comment)
You'll need to use something different, for example

<template x-for="item in items">
    <a :id="`menu-${item.id}`" x-text="item.label" :href="item.href" @mouseenter="active = item.id"></a>
</template>
init() {
    this.$nextTick(() => {
        this.$watch('active', (value) => {
            if (value !== null) {
                document.getElementById(`menu-${value}`).focus();
            }
        });
    });
}

Replies: 1 comment 1 reply

Comment options

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

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