Skip to content

Use of event modifier #212

Answered by edwardspresume
ariomoklo asked this question in Help
Discussion options

You must be logged in to vote

I am new to svelte, and found that in svelte there is event modifier that you can chain in some event like on:click|preventDefault. But beside once, event modifier can be used in DOM elements only. Is there a way to channel the modifiers or some other way to so that event modifier can be used in shadcn components ?

I am curious if the modifiers can still be used in a simple way as well. For now, using a function is a workaround, for example:

function handleClick(event: Event) { event.stopPropagation(); // rest of code }

<Button on:click={handleClick} />

Replies: 1 comment 1 reply

Comment options

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

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