Cannot read property 'nodeName' of null, ONLY the first time I try to sort a table
Cannot read property 'nodeName' of null, ONLY the first time I try to sort a table
This is a weird issue, which results in
[code] Cannot read property 'nodeName' of null [/code] in [code] jquery.dataTables.min.js:105 [/code]
The error pops out only once, the first time I try to sort a table column. The table with not sort, but I will get the above error. Once the error appears, sorting works, and I dont get the error anymore. I suppose the first instance of sorting happens before nodeName being defined???
The page is deployed on my local laptop, so I cannot link to the whole page.
Here are links to the javascript that defines the table, and the html code, that goes with it:
http://pastebin.com/09Rf6gVF
http://pastebin.com/BnuaxEGn
Here is the live preview, but it works ok :(
http://live.datatables.net/ipusag/5/edit
[code] Cannot read property 'nodeName' of null [/code] in [code] jquery.dataTables.min.js:105 [/code]
The error pops out only once, the first time I try to sort a table column. The table with not sort, but I will get the above error. Once the error appears, sorting works, and I dont get the error anymore. I suppose the first instance of sorting happens before nodeName being defined???
The page is deployed on my local laptop, so I cannot link to the whole page.
Here are links to the javascript that defines the table, and the html code, that goes with it:
http://pastebin.com/09Rf6gVF
http://pastebin.com/BnuaxEGn
Here is the live preview, but it works ok :(
http://live.datatables.net/ipusag/5/edit
This discussion has been closed.
Replies
Allan
I managed to upload the code, with a test database. I also switched to non mini version of datatables. Now the error is fired EVERY time, not only the first .
The error is in line
[code]jquery.dataTables.js:5698 [/code]
> var bet = formatTable.fnGetData($('body').data("chosenTR"));
You are passing in a jQuery object, but fnGetData expects a node. Use:
[code]
var bet = formatTable.fnGetData($('body').data("chosenTR")[0]);
[/code]
DataTables 1.10's new API will be able to cope with jQuery objects being passed in :-)
Allan
[code]
$('body').on('click', "tr", function() {
....
"chosenTR": formatTable.fnGetPosition($(this).closest('tr')[0])
...
var bet = formatTable.fnGetData($('body').data("chosenTR"));
[/code]
I try to get all values located in a row, addressing the first cell. Since the function triggers on every tr clicked, it will trigger on thead when I want to sort, too, but the value will be null, so the error.
Case closed