Skip to content

Dispatch custom event to <template> clone element #4405

Discussion options

You must be logged in to vote

You are dispatching the event too early, you need to allow Alpine to initialise the component, javascript is a single-threaded language and can only do one thing at the time. Use nextTick to queue the event after the component has been created.
You can access data directly by using Alpine.$data as well (again, you need to wait one tick).
See https://codepen.io/SimoTod/pen/abewqgz

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@NilsWeinander-KulturIT
Comment options

Answer selected by NilsWeinander-KulturIT
Comment options

You must be logged in to vote
3 replies
@NilsWeinander-KulturIT
Comment options

@ekwoka
Comment options

@NilsWeinander-KulturIT
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants