mercredi 17 juin 2020

Correct way to check if yajra/laravel table was already initialized?

In use laravel 5.7 / jquery 3 / blade app I use yajra/laravel-datatables-oracle 8 and open it in modal dialog and I open this dialog for the 2nd/3rd time I got warning message :

DataTables warning: table id=get-fee-dt-listing-table - Cannot reinitialise DataTable

In blade file :

<div class="modal-body">

    <div class="table-responsive dataTables_header">
        <table class="table table-bordered table-striped text-primary" id="get-fee-dt-listing-table">
            <thead>
            <tr>
                <th></th>

and in .js file:

bookingsAndAvailability.prototype.showFeesSelection = function () {
    console.log('showFeesSelection::')
    $("#div_check_in_fees_modal").modal({
        "backdrop": "static",
        "keyboard": true,
        "show": true
    });



    // var dtListingTable= document.getElementById('get-fee-dt-listing-table')
    // dtListingTable  = null // If to uncomment these 2 lines - they do not help

    $("#get-fee-dt-listing-table").html('') // // If to uncomment these 2 lines - they do not help

    oTable = $('#get-fee-dt-listing-table').DataTable({
        processing: true,
        language: {
            "processing": "Loading fees..."
        },

I close the modal with command :

$("#div_check_in_fees_modal").modal('hide');

which is correct way to check if table was already initialised?

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3ebO0Gq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire