File tree 1 file changed +7
-32
lines changed
packages/svelte/tests/runtime-runes/samples/bind-group-nested-data 1 file changed +7
-32
lines changed Original file line number Diff line number Diff line change 2
2
import { writable } from ' svelte/store' ;
3
3
4
4
let menu = [' Cookies and cream' , ' Mint choc chip' , ' Raspberry ripple' ];
5
- let order = writable ({ flavours: [' Mint choc chip' ], scoops: 1 });
5
+ let order = writable ({ iceCream: [{flavours: [' Mint choc chip' ]}], scoops: 1 });
6
+ let index = 0
6
7
</script >
7
8
8
9
<form method =" POST" >
9
- <h2 >Size</h2 >
10
-
11
- <label >
12
- <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={1 } />
13
- One scoop
14
- </label >
15
-
16
- <label >
17
- <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={2 } />
18
- Two scoops
19
- </label >
20
-
21
- <label >
22
- <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={3 } />
23
- Three scoops
24
- </label >
25
-
26
- <h2 >Flavours</h2 >
10
+ <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={1 } /> One scoop
11
+ <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={2 } /> Two scoops
12
+ <input type ="radio" bind:group ={$order .scoops } name ="scoops" value ={3 } /> Three scoops
27
13
28
14
{#each menu as flavour }
29
- <label >
30
- <input
31
- type =" checkbox"
32
- bind:group ={$order .flavours }
33
- name =" flavours"
34
- value ={flavour }
35
- />
36
- {flavour }
37
- </label >
15
+ <input type ="checkbox" bind:group ={$order .iceCream [index ].flavours } name ="flavours" value ={flavour } /> {flavour }
38
16
{/each }
39
17
</form >
40
18
41
- <div >
42
- <h2 >Current flavours</h2 >
43
- <span id ="output" >{$order .flavours .join (' +' )}</span >
44
- </div >
19
+ <div id ="output" >{$order .iceCream [index ].flavours .join (' +' )}</div >
You can’t perform that action at this time.
0 commit comments