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

TypeError: Cannot read property 'parentNode' of null on Angular way #150

Closed
MaicolBen opened this issue Dec 11, 2014 · 3 comments
Closed

Comments

@MaicolBen
Copy link

Hi,

I've a strange error that i can't reproduce it on plunker (the real application have numerous plugins), the angular-datatable throw "TypeError: Cannot read property 'parentNode' of null" in this line.

Why nTableWrapper property in settings could be null?

Any help is appreciated!

@l-lin
Copy link
Owner

l-lin commented Dec 12, 2014

The nTableWrapper contains the DOM that DataTable built:
image
Normally, it should not be null.

Try to buil a table without any additional plugins and with the simplest configuration.
Then add one plugin at a time to identify the culprit.

@MaicolBen
Copy link
Author

The table haven't plugins, it seems to me that the table is not ready when the directive is applied. Because when I create other directive that apply the plugin after a second work! But the behavior is slow:

.directive('myDatatable', function($compile, $timeout){
    return function(scope, elem, attr) {
        $timeout(function(){
            elem.attr('datatable', 'ng');
            elem.removeAttr('my-datatable');
            $compile(elem)(scope);
        }, 1000);
  };
})

@nashtsai
Copy link

I have exactly the same problem as well, I've spotted this problem is caused by:

DTDefaultOptions.setLanguageSource('http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/xxxx.json')

or

$scope.dtOptions = DTOptionsBuilder
    .newOptions()
    .withLanguage({
       sUrl:'http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/xxxx.json'
      })

Suspected that due to language resources is received asynchronously and applied after data models has been set into datatable caused this problem.

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

No branches or pull requests

3 participants