Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
EditableCard.svelte
<!--
"Bound functions" by Enrico; github.com/theetrain
This demonstrates ways to communicate from a parent component to a child
using bound functions.

Alternatives are: context, writable stores, bound props

See refactor, "flag prop": https://svelte.dev/repl/95e9c37810514eddb6f8282f3678c31a?version=4.2.9
-->

<script>
import EditableCard from './EditableCard.svelte'
let editCard
let doneEdit

const submit = () => {
console.log('submitted')
doneEdit()
}
</script>

<h1>Let's edit this card</h1>
<p>
<button on:click={editCard}>Edit card</button>
</p>
<form on:submit|preventDefault={submit}>
<EditableCard
bind:edit={editCard}
bind:doneEdit
name="Enrico"
/>
</form>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */