yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.76k stars 857 forks source link

[if BLOCK] places at bottom of table rendering #3155

Closed pjsv1990uji closed 4 months ago

pjsv1990uji commented 4 months ago

Summary of problem or feature request

Hello, excuse me, can you help me? I am trying to use the datatable with Laravel 11 and Livewire 3, when rendering the table with the code that I put below it set this: <!- - [if ENDBLOCK]><![endif]--> at the end, so this causes an error. I don't know where this is doing this, or if I'm using {{ $dataTable->scripts(attributes: ['type' => 'module']) }} wrong. I was following the tutorial of [https://yajrabox.com/docs/laravel-datatables/11.0/quick-starter]() Thanks for your help

Code snippet of problem

    <div class="container">
        <div class="card">
            <div class="card-header">Manage Users</div>
            <div class="card-body">
                {{ $dataTable->table() }}
            </div>
        </div>
    </div>

    @push('scripts')
        {{ $dataTable->scripts(attributes: ['type' => 'module']) }}
    @endpush
</div>

System details

<script type="module">$(function(){window.LaravelDataTables=window.LaravelDataTables||{};window.LaravelDataTables["users-table"]=$("#users-table").DataTable({"serverSide":true,"processing":true,"ajax":{"url":"http:\/\/127.0.0.1:8000\/gestion\/usuarios","type":"GET","data":function(data) {
            for (var i = 0, len = data.columns.length; i < len; i++) {
                if (!data.columns[i].search.value) delete data.columns[i].search;
                if (data.columns[i].searchable === true) delete data.columns[i].searchable;
                if (data.columns[i].orderable === true) delete data.columns[i].orderable;
                if (data.columns[i].data === data.columns[i].name) delete data.columns[i].name;
            }
            delete data.search.regex;}},"columns":[{"data":"id","name":"id","title":"Id","orderable":true,"searchable":true,"visible":false},{"data":"name","name":"name","title":"Nombre","orderable":true,"searchable":true},{"data":"lastname","name":"lastname","title":"Apellido","orderable":true,"searchable":true},"buttons":[{"extend":"excel"},{"extend":"csv"},{"extend":"pdf"},{"extend":"print"},{"extend":"reset"},{"extend":"reload"}]});});
<!--[if BLOCK]><![endif]--><!--[if ENDBLOCK]><![endif]--></script>