Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

insertBefore may fail using the AngularWay #91

Closed
nicoabie opened this issue Oct 7, 2014 · 9 comments
Closed

insertBefore may fail using the AngularWay #91

nicoabie opened this issue Oct 7, 2014 · 9 comments
Labels

Comments

@nicoabie
Copy link

nicoabie commented Oct 7, 2014

It seems that sometimes its second param (settings.nTableReinsertBefore the datatables loading message) is not yet inserted in the DOM
Throwing "Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node."

I couldn't found the cause of it to happen, but a "fix" I've found was

try {
    orig.insertBefore(table, settings.nTableReinsertBefore);    
}catch(ex){
    console.log(ex);
    orig.appendChild(table);
}

To force its replication, render a table using the angularway, remove from dom the loading message and render it again.

@l-lin
Copy link
Owner

l-lin commented Oct 8, 2014

Mmh can you provide a code (preferably a plnkr, fiddle or something alike) that can reproduce the problem?

@nicoabie
Copy link
Author

nicoabie commented Oct 8, 2014

I will try to put a fiddle, but you will have to remove manually the loading message to replicate it. It fails sometimes if not.

@l-lin l-lin added the bug label Oct 9, 2014
@l-lin l-lin closed this as completed Oct 9, 2014
@hyades
Copy link

hyades commented Dec 15, 2014

Any updates? Adding this way seems to remove the handlers attached to some of the elements of my table.

@l-lin
Copy link
Owner

l-lin commented Dec 15, 2014

Can you provide an example that reproduces your problem? Because I do not have this issue.

@noteStylet
Copy link

I have the same Problem.
The problem is when you have multiple tabs that contains angular-datatables.
And when a new data arrives, the error is throwed as many times we have tabs.

I am using bootstrap tabs,
and if I have a 5 tabs, when a new data arrives, the error is thrown 5 times.

So I understand that he will modify the DOM, but the DOM dosn't exist because we can show 1 tab a time.

@l-lin
Copy link
Owner

l-lin commented Feb 11, 2015

Using Angular Bootstrap, I do not have this issue.
I don't know about using only Bootstrap though...

@zafra6
Copy link
Contributor

zafra6 commented May 12, 2015

Hey guys, maybe we can use an if-else validation instead of a try-catch validation. I'm working with multiple AngularWay datatables, so sometimes in console appears this exception (DOMException), that made think that something is wrong when actually is not. Besides I think it'll improve the performance


if(orig.contains(settings.nTableReinsertBefore)){
     orig.insertBefore(table, settings.nTableReinsertBefore);
} else {
     orig.appendChild(table);
}

@SeoRoman
Copy link

Also, I am using angular bootstrap, using tabset and tab and also having the same issue as mentioned above.

issue...

table datatable="ng" // primary,

click on edit (opened modal, with angular tabs) one of the tabs has another datatable = "ng" and the Node error pops up...

Using Zafra6's solution has resolved the issue :)

@geeklisted
Copy link

Interestingly, I am not using tabs (bootstrap or otherwise) but I am using static dataTables and am encountering this issue. I modified angular-datatables.js with zafra6's suggestion and the exception is actually being thrown to the console.

I wonder if just removing the log.warn(ex) from the original try-catch is a better solution for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants