Datatable with Laravel Blade include Error

Datatable with Laravel Blade include Error

andersonaltissimoandersonaltissimo Posts: 7Questions: 1Answers: 0

Good afternoon,
I am having a problem when I use a Laravel include with my Datatable on more than one view.

In the First View that I open is working, but the second give me a error, for me looks that is trying to search the table instead of repopulating.

Blade Include:

<div class="mail-box">
    @include('pages.messages.message-list', ['formType' => "inbox"])
</div>

HTML (pages.messages.message-list):

<input type="hidden" value="{{$formType}}" id="formType">
<table id="message-datatable-list" class="table table-striped table-bordered table-hover dataTables-example">
    <thead>
        <tr>
            <th></th>
            <th>Creator</th>
            <th>Subject</th>
            <th>Created At</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th></th>
            <th>Creator</th>
            <th>Subject</th>
            <th>Created At</th>
        </tr>
    </tfoot>
</table>

JS:

$('#message-datatable-list').DataTable({
        "columnDefs": [
            {className: "select-checkbox", "targets": [0]},
            {width: "5%", "targets": 0},
            {width: "30%", "targets": 1},
            {width: "35%", "targets": 2},
            {width: "20%", "targets": 3},
            {orderable: false, targets: [0, 3]},
            {"name": "creator", "targets": 1},
            {"name": "subject", "targets": 2},
            {"name": "create_at", "targets": 3},
        ],
        "select": {
            style: 'multi',
            selector: 'td:first-child'
        },
        "order": [[1, "asc"]],
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "messages/search/datatable",
            "data": function (d) {
                d.formType = $('#formType').val();
            }
        },
        "createdRow": function (row, data, dataIndex) {

            $(row).attr('data-uuid', data[4]);

            if (data[5] === false) {
                $(row).addClass('read')
            } else {
                $(row).addClass('unread')
            }
        },
    });

This question has accepted answers - jump to:

Answers

This discussion has been closed.