

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


<script type="module">
  $(document).ready(function(){
    // Editor edit
    $("#dataTable_piatto").on('click', 'a.editor_edit', function (e) {
      e.preventDefault();
      window.LaravelDataTables["dataTable_piatto-editor"].edit( $(this).closest('tr'), {
        title: 'Modifica',
        buttons: 'Aggiorna',
      });
    });

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

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

  });

</script>

<script>
  function initComplete_piatto(){
    $('div.dt-buttons button').removeClass('btn-secondary');
    $('div.dt-search').addClass('mt-0 mb-4');
    $('div.btn-group').removeClass('btn-group');
    return;
  }

  function aggiornaPiattoDataTable(categoria_id) {
  const dt = window.LaravelDataTables["dataTable_piatto"];
  dt.settings()[0].ajax.data = function(d) {
    d.categoria_id = categoria_id;
  };
  dt.ajax.reload();
}

function GoToAllPiatti() {
  window.location.href = "{{ route('piatto.index') }}";
}

function GoToCucine() {
  window.location.href = "{{ route('cucina.index') }}";
}

</script>