DataTable-Objects are not independent?

DataTable-Objects are not independent?

Alle_XAlle_X Posts: 7Questions: 1Answers: 0

Hi.
After searching a couple minutes (about 80-100) I found a behavior that I can't explain. Perhabs sb could give me a hint?

So, this code is working as expected. ANd if I don't delete them, I see my 2 well formated tables.

table0 = $('#tabelle0').DataTable();
table1 = $('#tabelle1').DataTable();
table1.destroy();
table0.destroy();

On the other side, this code:

table0 = $('#tabelle0').DataTable();
table1 = $('#tabelle1').DataTable();
table0.destroy();
table1.destroy();

produces the JS-error-output in the JS-console: "Uncaught DOMException: Node.insertBefore: Child to insert before is not a child of this node".

That means, these objects are not really independent? Is there a datatable-DOM-principle I didn't understand?

Thank you.

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited March 2021

    Placing your code snippets in this test case show it works destroying in either order works:
    http://live.datatables.net/piyajiqo/1/edit

    Please update the test case to show the issue.

    Are these statements initializing your Datatables or just getting the API?

    table0 = $('#tabelle0').DataTable();
    table1 = $('#tabelle1').DataTable();
    

    Kevin

  • Alle_XAlle_X Posts: 7Questions: 1Answers: 0
    edited March 2021

    Thank you for your answer.

    http://live.datatables.net/vedifogu/1/edit shows the error with my dataset. It seems that there is something wrong in my dataset, but I don't find a clue.

    Thank you looking over it.Perhabs there is a reaon for more than this behavior I'm fighting on...

    PS: I guess, I'm initializing the Datatables with these statements...

  • Alle_XAlle_X Posts: 7Questions: 1Answers: 0
    edited March 2021

    Got it!

    The error occures, if you write the HTML between the two tables this way:

    </table><table id="example1" class="display nowrap" width="100%">
    

    and works with that definition

    </table>
    <table id="example1" class="display nowrap" width="100%">
    
This discussion has been closed.