Testing if DT object exists?
Testing if DT object exists?
morissette
Posts: 16Questions: 4Answers: 1
In 1.9.x I could do:
if (mainTable.length) {
mainTable.row(row).remove().draw();
} else {
dashTable.row(row).remove().draw();
}
I'm converting everything to 1.10.x and this code is no longer working.
This discussion has been closed.
Answers
There wasn't a
row()
method in DataTables 1.9, so I don't understand how that code would have worked there...Can you please link to a test case showing the issue.
Allan
Hi,
I'm aware that row() did not exist in 1.9, I have updated the code for 1.10 but my check for if this is mainTable or dashTable does not work any longer.
Internal Site that is not public so I cannot provide test case let me see if I can fiddle this:
http://jsfiddle.net/2ejVx/7/
1.9 and 1.10 versions are in commented in the fiddle. 1.9 works, 1.10 doesnt.
Looks like you are mixing the old API with the new. They cannot both be access from the same object. See the manual: http://datatables.net/manual/api#Accessing-the-API
Allan
That is just showing you the old code and the new code which is why there are comments there explaining it. The old code worked properly before the upgrade to 1.10 but now mainTable.length always tests false. I am looking for a way to test this properly.
Alright I just did if ( mainTable ) and that works fine now.