<div class="card h-100">
    <div class="card-body">
      {{ $dataTable_gruppo->table() }}
    </div>
  </div>

  {{ $dataTable_gruppo->scripts(attributes: ['type' => 'module']) }}

  <script type="module">

  $(document).ready(function(){
    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': '{{csrf_token()}}'
      }
    });

    // Editor edit
    $("#dataTable_gruppo").on('click', 'a.editor_edit', function (e) {
      e.preventDefault();
      window.LaravelDataTables["dataTable_gruppo-editor"].edit( $(this).closest('tr'), {
        title: 'Modifica',
        buttons: 'Aggiorna',
      });
    });

    // Editor delete
    $("#dataTable_gruppo").on('click', 'a.editor_delete', function (e) {
      e.preventDefault();
      window.LaravelDataTables["dataTable_gruppo-editor"].remove($(this).closest('tr'), {
        title: 'Cancella record',
        message: 'Sei sicuro di voler eliminare il record selezionato?',
        buttons: 'Cancella record'
      });
    } );

    $("#dataTable_gruppo").on('dblclick', 'tbody td', function (e) {
      window.LaravelDataTables["dataTable_gruppo-editor"].edit( $(this).closest('tr'), {
        title: 'Modifica',
        buttons: 'Aggiorna',
      });
    });

  });
</script>

<script>
  function initComplete_gruppo(){
    $('div.dt-buttons button').removeClass('btn-secondary');
    return;
  }
</script>
