Chosen does not work with laravel

0

I'm trying to use Bootstrap + Chosen with laravel within modal, but it just does not work. I made all the imports and nothing

Imports I did like this:

<link href="{{ asset('css/chosen.min.css') }}" type="text/css" rel="stylesheet" >
<script src="{{ url('js/bootstrap.js') }}"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"integrity="sha384-I6F5OKECLVtK/BL+8iSLDEHowSAfUo76ZL9+kGAgTRdiByINKJaqTPH/QVNS1VDb" crossorigin="anonymous"></script>    
<script src="{{ url('js/chosen.jquery.min.js') }}"></script>

What I would like to see happen is more or less as follows in the code below

$('.btn-botao').on('click', function(){
   $('.modal').modal('show');
});


$('.modal').on('shown.bs.modal', function () {
    $('select', this).chosen('destroy').chosen( {allow_single_deselect: true} );         
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.jquery.min.js"></script><ahref="#" class="btn btn-primary btn-botao">Clique aqui</a>

<div class="modal fade">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <select class="form-control" data-placeholder="Selecione">
          <option  value="0"></option>
          <option  value="1">Opção 1</option>
          <option  value="2">Opção 2</option>
        </select>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary">Save changes</button>
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

Help me, please!

    
asked by anonymous 24.11.2017 / 13:44

1 answer

1

Are the include links of the js in the header working? If so, try changing the js. Try this:

$(document).on('show.bs.modal', '.myModal', function () {
    $('#meu_select').chosen('destroy').chosen( {allow_single_deselect: true} );       
})
    
24.11.2017 / 14:29