Skip to content
Discussion options

You must be logged in to vote

Pass it into the function, it's easier

<div x-data>
    <button @click="$dropdown($refs.dropdown)" type="button">
        Menu
    </button>
    <ul class="dropdown" x-ref="dropdown">
        <li><a href="#">Item</a></li>
        <li><a href="#">Item</a></li>
    </ul>
</div>

<script>
    document.addEventListener('alpine:init', () => {

        // Magic: $tooltip
        window.Alpine.magic('dropdown', el => dropdown => {
           let instance = tippy(el, { 
                content: dropdown,
                trigger: 'manual',
                placement: 'bottom',
                interactive: true,
                allowHTML: true,
            })
 
            instance.show()
        })

Replies: 2 comments 1 reply

Comment options

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

Answer selected by aaronstezycki
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