Plugins do not work in my modal window

0

I have a web app in laravel 5.5, I have several manners for registrations, validation for generic fields such as country I use select2 , and it runs perfect in all views of the application, except in manners, I even tried to place a table with datatable and noticed that it loads the first time (sometimes) and then it does not return to show the stylized table, my JS scripts are in a separate .js file, but as a test I have placed them in the layout /app.blade.php, in the view that calls the modal and in the same modal, none without success, any recommendations?

action.js

$( function() {
var countries =   
["Afghanistan","Albania",....,"Venezuela","Vietnam","Virgin Islands 
(US)","Yemen","Zambia","Zimbabwe"];
$( "#pais" ).select2({
  data: countries
});});

layout / app.blade.php

....
@yield('content')
....
<!-- MODAL-->
<div class="modal fade" id="scrollmodal" tabindex="-1" role="dialog" aria- 
labelledby="scrollmodalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
  </div>
</div>
<!-- END MODAL-->
@yield('js')
<script src="{{asset ('js/action.js')}}"></script>

quotations / create.blade.php (view that calls the modal)

@section('content')
<a id="triggerClient" href="#scrollmodal" data-toggle="modal" class="btn 
 btn-success btn-sm">
    <i class="zmdi zmdi-account-add"></i>
 </a>
@endsection
@section('js')
<script>
$('#triggerClient').on('click', function (event) {
  var button = $(event.relatedTarget); // Button that triggered the modal
  $.ajax({
    url: '{{route('cliente.create')}}',
    method:'GET',
    data:{},
    success:function(data)
    {
      $('#scrollmodal').html(data).modal('show');

      $('#canc').on('click', function (event) { $('.evento').html(''); });
    },
    error:function(data){
      console.log(data);
    }
  });
 });
 $('#canc').click(function(){
 $('#scrollmodal').modal('hide');
 })

</script>
@endsection

client / create.blade.php

 <div class="modal-dialog modal-lg" role="document">
  <meta name="_token" content="{{ csrf_token() }}"/>
   <div class="modal-content">
    <div class="modal-header">
      <h5 class="modal-title" id="scrollmodalLabel">Crear <b>Cliente</b> 
      </h5>
      <button type="button" class="close" data-dismiss="modal" aria- 
       label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
     </div>
     <div class="modal-body">
      <form action="" method="post">
        <select name="pais" id="pais">
          <option value="">Seleccione un país</option>
        </select>
      </form>
     </div>
  </div>
 </div>
    
asked by Jhosno 08.11.2018 в 17:07
source

0 answers