Skip to content

Commit 7681ed0

Browse files
authored
[docs] Document the effect of the order of bind: and on: (#6887)
1 parent 4cc439a commit 7681ed0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

site/content/docs/02-template-syntax.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,22 @@ On `<input>` elements with `type="file"`, you can use `bind:files` to get the [`
602602
/>
603603
```
604604

605+
---
606+
607+
`bind:` can be used together with `on:` directives. The order that they are defined in determines the value of the bound variable when the event handler is called.
608+
609+
```sv
610+
<script>
611+
let value = 'Hello World';
612+
</script>
613+
614+
<input
615+
on:input="{() => console.log('Old value:', value)}"
616+
bind:value
617+
on:input="{() => console.log('New value:', value)}"
618+
/>
619+
```
620+
605621

606622
##### Binding `<select>` value
607623

0 commit comments

Comments
 (0)