destroy(false) still removes table

destroy(false) still removes table

ButchNZButchNZ Posts: 20Questions: 6Answers: 0
edited February 2023 in Free community support

With version 1.13.1 this code:

relatedTable.clear().destroy(false);

Does seem to delete all the table dom.

I say seems as this is a Laravel Livewire app which does change the dom a lot.

I'm updating some values in the table which Livewire does but removes the Datatables functionality from it so I needed to reinitialise.

If I cache the table dom before I clear().destroy() then reinsert it and reinit the table it seems to work. For example:

    var cache = false;

    if ($.fn.dataTable.isDataTable('#RelatedProjectTable'))
    {
        cache = $('#TableWrapper').html();
        relatedTable.clear().destroy(false);
    }

    setTimeout(function(){
        if (cache)
        {
            $('#TableWrapper').html(cache);
        }
        
        relatedTable = $('#RelatedProjectTable').DataTable(conf);
    }, 1000);

Answers

Sign In or Register to comment.