Answers for "select2 not working livewire"

1

select2 in modal not work

//replace it with your script
<script>
    $('#mySelect2').select2({
        dropdownParent: $('#myModal')
    });
</script>
Posted by: Guest on December-15-2020
1

select2 with livewire

<div class="form-group col-md-3">
              <label class="text-sm"for="division_id">Division</label>
                <select  class="form-control select2 {{ $errors->has('division_id') ? 'is-invalid' : '' }}"
                    wire:model="division_id" id="division_id"  >
                    <option value=''>{{ trans('global.pleaseSelect') }}</option>
                    @foreach($divisions as $id =>  $division) 
                            <option value="{{ $id }}"  {{ old('division_id') == $id ? 'selected' : '' }}> {{ $division->division }} </option>  
                    @endforeach
             </select> 
         </div>


<script>
   document.addEventListener('livewire:load', function () {
    
        $('#division_id').on('select2:select', function (e) {
     
            @this.set('division_id', e.target.value);
        });
        
     });  
</script>
Posted by: Guest on August-18-2021

Code answers related to "select2 not working livewire"

Code answers related to "Javascript"

Browse Popular Code Answers by Language