Testing if DT object exists?

Testing if DT object exists?

morissettemorissette Posts: 16Questions: 4Answers: 1
edited May 2014 in DataTables 1.10

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.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    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

  • morissettemorissette Posts: 16Questions: 4Answers: 1

    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.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Can you please link to a test case showing the issue.

    Allan

  • morissettemorissette Posts: 16Questions: 4Answers: 1
    edited May 2014

    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.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    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

  • morissettemorissette Posts: 16Questions: 4Answers: 1

    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.

  • morissettemorissette Posts: 16Questions: 4Answers: 1

    Alright I just did if ( mainTable ) and that works fine now.

This discussion has been closed.