Hello guys,
I’m trying to get the value of select onchange with livewire and select2 jquery but when I start select2 I can’t get the value, without select2 the value gets normally.
Code without select2 working normally:
<select class="form-control @error('tipo') is-invalid @enderror" wire:change="setSomeProperty($event.target.value)" name="tipo" value="{{ old('tipo', @$doc->id_tipo_nota) }}" >
<option value="">Selecione..</option>
@forelse ($tnfs as $tnf)
@if (@$doc->id_tipo == $tnf->id_tipo_nota || old('tipo') == $tnf->id_tipo_nota)
<option selected='selected' value="{{ $tnf->id_tipo_nota }}">{{ $tnf->nome }}</option>
@else
<option value="{{ $tnf->id_tipo_nota }}">{{ $tnf->nome }}</option>
@endif
@empty
@endforelse
</select>
Code with select2 does not work:
<select class="form-control select2 @error('tipo') is-invalid @enderror" wire:change="setSomeProperty($event.target.value)" name="tipo" value="{{ old('tipo', @$doc->id_tipo_nota) }}" >
<option value="">Selecione..</option>
@forelse ($tnfs as $tnf)
@if (@$doc->id_tipo == $tnf->id_tipo_nota || old('tipo') == $tnf->id_tipo_nota)
<option selected='selected' value="{{ $tnf->id_tipo_nota }}">{{ $tnf->nome }}</option>
@else
<option value="{{ $tnf->id_tipo_nota }}">{{ $tnf->nome }}</option>
@endif
@empty
@endforelse
</select>
Help please.