Can not read parent node of null while destroying a data table even after checking if it is datatabl

Can not read parent node of null while destroying a data table even after checking if it is datatabl

FrehiwotFrehiwot Posts: 3Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Can not read parent node of null:

This problem does not show all time. At some point it will get thrown and data table won't be populated and i have to reload it . After reloading it the problem will disappear. I know that the problem is related to destroy and I tried to check if dt Instance is a data table before destroying it, but no luck. I tried to look in to different posts, but i could not find the working one.

The problem is on file jquery.datatables.js
var orig = settings.nTableWrapper.parentNode;

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,769
    edited March 2021

    Maybe its a timing issue since it looks like the issue is with promise. Can you show your code where you are destroying the Datatable? Is there an ajax request happening at the same time?

    Are you using jQuery empty. See this thread for an example.

    Kevin

  • FrehiwotFrehiwot Posts: 3Questions: 1Answers: 0

    The following is the way i used to destroy

    this.dtElement.dtInstance.then((dtInstance: DataTables.Api) => {
    console.log(dtInstance);
    if($.fn.dataTable.isDataTable(dtInstance))
    {
    dtInstance.destroy();
    console.log("aftre destroy")
    this.dtTrigger.next();
    }
    });

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,769

    Did you see my comment and thread about using jQuery empty()? Maybe you should try it. If it doesn't help then, as Colin mentioned, we will need to see the problem to help debug.

    Kevin

This discussion has been closed.