Tell choices that the list has changed with the setChoices method
Mar 30, 2024
3
Level 2
Livewire with Alpine and Choices.js
Hi, i am trying to use Choices.js on my selects however when i am saving or creating a new entry to the database the wire:model finds the old value but does not display the current option. here is my code:
<x-select.choices :options="$areas" wire:model="area_id" name="area_id" id="area_id"/>
<select
{{ $attributes }}
x-data
x-init="new Choices($el, {
searchEnabled: false,
allowHTML: true
})"
:multiple
>
<option value="">Select</option>
@foreach($options as $option)
<option value="{{ $option->id }}">{{ $option->name }}</option>
@endforeach
</select>
Any ideas?
Thank you
Level 122
1 like
Please or to participate in this conversation.