Cannot read property 'parentNode' of null
Cannot read property 'parentNode' of null
tartarichi
Posts: 2Questions: 1Answers: 0
Using a datatable if i'm very fast to click one of rows, when the click function invoke
table.row($(this)).data().idresidente;
I can see the error
jquery.dataTables.min.js:137 Uncaught TypeError: Cannot read property 'parentNode' of null
at s.<anonymous> (jquery.dataTables.min.js:137)
at s.iterator (jquery.dataTables.min.js:99)
at s.<anonymous> (jquery.dataTables.min.js:137)
at s.destroy (jquery.dataTables.min.js:102)
at n.fn.init.fnDestroy (jquery.dataTables.min.js:79)
at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:83)
at Function.each (jquery-1.12.4.min.js:2)
at n.fn.init.each (jquery-1.12.4.min.js:2)
at n.fn.init.m [as dataTable] (jquery.dataTables.min.js:82)
at n.fn.init.h.fn.DataTable (jquery.dataTables.min.js:164)
This is the complete code of the table.
var table1 = $('#tabellaricerca').DataTable({
data : data.result,
columns : [
{
data : "idresidente"
},
{
data : "nome"
}
]
});
$('#tabellaricerca tbody').on('dblclick', 'tr',
function() {
var idResidente = table1.row($(this)).data().idresidente;
});
If i make the same action slower there's no error.
It seems that the data are not yet available to ".data()"
What am I doing wrong?
Thanks so much for the help.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Happy to take a look at a test case showing the issue. There isn't anything obviously wrong with that, although you could try passing in
this
rather than$(this)
.Allan
Thanks Allan !!
I hope I have found the problem: the destroy is very slow and before I made $ ('# tabellaricerca'). DataTable (). Destroy ();
When I built and populated the table, it was not finished yet.
In this case, not having to change the structure was enough to use a clear () and a draw ().