$.fn.DataTable.fnIsDataTable consistenly returns false.

$.fn.DataTable.fnIsDataTable consistenly returns false.

ericDeckerericDecker Posts: 15Questions: 0Answers: 0
edited October 2013 in General
Hello,

I'm loading DataTables on click, rather than page load and I'm trying to develop a test condition to know when I should be rendering the table or the click action should just perform other functions. So the function fnIsDataTable seemed to be perfect, however, I cannot get it to return anything but false. I've tried running this on a long setTimeout inside document.ready, in the table's draw callback and just straight up after the DataTable initialization in the click handler.

At first I thought it was because I'm using sScroll features and that when you use it, the ID is no longer visible in the page. However, I am able to successfully log the element to the console. And I took off the scrolling and it still happened.

Any advice?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Can you please link to a test case showing the issue, as noted in the forum rules.

    Example of it working: http://live.datatables.net/ifivej/edit#javascript,html

    Allan
  • ericDeckerericDecker Posts: 15Questions: 0Answers: 0
    Hi Allan,

    It's working now that I added the index selector. When I had been trying in the past I was working off of the Reference page where it does not use jQuery but document.getElementById. Perhaps it would be appropriate to update the Reference to use this jQuery methodology rather than the javascript getElementId approach which was consistently returning false?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Agreed. DataTables 1.10 integrates much more sensibly with jQuery. The update to this particular function isn't something I've made though - but will do now you've pointed it out. The only difficulty I foresee is that the jQuery object might reference some tables which are a DataTables and some which are not... That will just have to be mentioned in the documentation.

    Allan
This discussion has been closed.