Skip to content
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

Emit events to parent from modal opened using openModal()? #9

Open
hardingjam opened this issue Jan 11, 2022 · 3 comments
Open

Emit events to parent from modal opened using openModal()? #9

hardingjam opened this issue Jan 11, 2022 · 3 comments

Comments

@hardingjam
Copy link

Is it possible to dispatch events from a modal back to the component that called openModal()?

For example:

	const handleClick = () => {
		openModal(ListingModal, on:eventDisaptch={handleEvent});
	};
@mattjennings
Copy link
Owner

Unfortunately no, you'll have to use callback props to communicate back up. See this example: https://svelte.dev/repl/2f2d171a9ea7458191904cb2feb5a54c?version=3.38.2

I'm open to figuring out some way to handle events like this though, as that would be much more svelte-y.

@daevid66
Copy link

Hey, started to use svelte-modals (thanks for creating this!), and while I think the callback method works fine, I think it would be possible to add event listeners by adding them to $on, in a similar same way as in this example: https://svelte.dev/repl/5b495a6d61e64d0cabdb3657f100837c?version=3.18.2

Not sure if it's possible to infer the types that way, though.

@mattjennings
Copy link
Owner

@daevid66 oh this is very interesting, I'll definitely take a look at this approach!

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

No branches or pull requests

3 participants