Closed volnistii11 closed 2 years ago
There was a thought that maybe i need to add csrf_token somewhere?
I thought it was because of this that the breeze was blocking
Hmm, I decided to look into the console, and saw warnings and an error, which are not present in the version without laravel-breeze.
When you say component, is it livewire, blade, or Vue? I currently use blade components too and it works for me. Also tried Livewire and Vue but it's a bit buggy. For livewire, you need to use wire:ignore if I recall correctly.
Anyways, you should fix the console error first cause it seems like just a js issue since you already have a working state.
Here is an example blade component that uses AlpineJs too, you might get some idea. I removed some markup but I think you get the idea here. This is a very custom dataTable as global search is being handled via AlpineJS.
@props(['dataTable'])
<div {{ $attributes->merge(['class' => 'card']) }} x-data="{}">
<div class="card-header">
<div class="row justify-content-between align-items-center flex-grow-1 mt-2">
<div class="col-sm-4 col-md-3 mb-3 mb-sm-0">
<form @submit.prevent>
<div class="input-group input-group-merge input-group-flush">
<div class="input-group-prepend">
<div class="input-group-text">
<i class="tio-search"></i>
</div>
</div>
<input id="{{$dataTable->getTableAttribute('id')}}_search"
type="search"
class="form-control"
@keydown.debounce.750ms="LaravelDataTables['{{$dataTable->getTableAttribute('id')}}'].search($refs.search.value).draw();"
x-ref="search"
placeholder="Search..."
aria-label="Search...">
</div>
</form>
</div>
</div>
</div>
<div class="card-body" id="{{$dataTable->getTableAttribute('id')}}_infoContainer"></div>
<div class="table-responsive datatable-custom datatable-custom-centered">
{{ $table ?? $dataTable->table() }}
</div>
<x-data-table-footer :id="$dataTable->getTableAttribute('id')" />
</div>
@push('scripts')
{{ $scripts ?? $dataTable->scripts() }}
@endpush
<x-data-table :dataTable="$dataTable">
// some stuffs
</x-data-table>
Yes, blade components. How do you connect all the necessary js scripts? I was given the idea that it might have something to do with the namespace in js, but I don't understand anything in js. Maybe you have a mini project (on github for example) so that I can see what I'm doing wrong ... Because I have been suffering with this for almost a month, and so I did not find an answer (there are no examples on the Internet at all) ...
Here's another one of my attempts ... https://github.com/volnistii11/archive/blob/master/resources/views/service/format/index.blade.php
That is, apparently, I do not understand how to properly connect the required js ...
That is, apparently, I do not understand how to properly connect the required js ...
Try using https://datatables.net/download/ and build your requirements there.
I made a table using yajra datatables, everything works fine (buttons, table title, table data, editing, etc.)
Now I am trying to implement this using Laravel 8 components, but I do not understand how to do it correctly. I gave an example of one of my attempts below, but there I only display the column headings (there are no buttons, there is no data in the table).My attempt to go to Laravel 8 components only shows Laravel Breeze items and table column titles.
my DataTable Controller
I also attach two pictures, the first one shows the working state. The second is how it looks when I try to implement it using components. 1 2