178
rated 0 times
[
180]
[
2]
/ answers: 1 / hits: 17830
/ 8 Years ago, wed, september 28, 2016, 12:00:00
Is there a way to determine if a variable is an initialized DataTable or not? I'm basically trying to do this:
if (isDataTable(variable)) {
// datatable ... do datatable stuff
} else {
// not a datatable... do other stuff
}
I assumed $.fn.dataTable.isDataTable()
could be used, but this only works for table selectors, not for variables containing an initialized DataTable. This function is returning false for such variables (EDIT: the creator of DataTables has since extended $.fn.dataTable.isDataTable()
in this commit so that this is no longer true):
var table = $("#table").DataTable(); // Valid initialized DataTable
console.log($.fn.dataTable.isDataTable("#table")); // Returns true
console.log($.fn.dataTable.isDataTable(table)); // Returns false...why?
More From » jquery