-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Pass events to dynamic components #5265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Directives (like |
Thats what i currently do, write callbacks and dispatchers, very uncomfortable. I dont know which directives the passed components have. The question is then how can i pass directives dynamically to components? Or why it is not possible to pass them this way? Svelte creates bindings when you write it like this <MyComponent on:click={doSomething}></MyComponent> It would be nice if we can have access to set the bindings via a function, e.g. <script>
let myComponent
myComponent.addListener('click', doSomething)
</script>
<MyComponent bind:this={myComponent]></MyComponent> Internally svelte does the same. |
Closing as spreading events is supported in Svelte 5 |
errr, oops... this was already closed |
Is it possible to pass events to dynamic components?
E.g. pass
on:click
as props and recieve the click event.Made a full exmaple: https://svelte.dev/repl/a16dd36f0265408a9c42409986b44acd?version=3.24.1
Short Version:
Example.svelte
Example call
The
on:click
will not be triggered, only if i wrote it like thisBut in this case i have to call the click targets manually.
The text was updated successfully, but these errors were encountered: