Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 4d05af8

Browse files
committed
Provide better x-model support
1 parent 6978a4c commit 4d05af8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

resources/views/components/choice/switch-toggle.blade.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
},
1414
toggle() {
1515
this.value = this.isPressed ? this.offValue : this.onValue;
16+
$dispatch('input', this.value);
17+
@if ($hasXModel())
18+
{{ $attributes->first('x-model') }} = this.value;
19+
@endif
1620
},
1721
}"
1822
wire:ignore.self
1923
class="{{ $getContainerClass() }}"
20-
@if ($hasXModel())
21-
x-init="$watch(value, newValue => { {{ $attributes->first('x-model') }} = newValue })"
22-
@endif
2324
{{ $extraAttributes }}
2425
>
2526
@if ($label && $labelPosition === 'left')

0 commit comments

Comments
 (0)