Problems with css and js of Select2 in laravel

0

I am using laravel with an AdminLte template that supposedly brings the css and js of Select2, a package that I need to have multiselects, but it does not work it simply puts the multiselect of html flat. What may be happening, I am using this code:

<select class="js-example-basic-multiple" name="permissions" multiple="multiple">
    @foreach($permission as $per)
      <option value="{{$per->id}}" >{{$per->display_name}}</option>
    @endforeach
</select>
    
asked by Luis Dariel Valenciano 22.03.2018 в 14:39
source

1 answer

1

Possibly, even though the css and js files are in the template you have to assign them to the elements you need, for example:

 <select class="js-example-basic-multiple" name="permissions" multiple="multiple">
   @foreach($permission as $per)
    <option value="{{$per->id}}" >{{$per->display_name}}</option>
   @endforeach
</select>

    //Al final de tu html o en tu archivo js relacionado
       <script>
        $(document).ready(function() {
            $('.js-example-basic-multiple').select2();
        });
       </script>

Then, if it works, check the errors in the javascript console to see if it asks for the js or css files.

    
answered by 22.03.2018 / 14:46
source