BUG: table.row(...).node(...).to$ is not a function
BUG: table.row(...).node(...).to$ is not a function
mooseburger
Posts: 6Questions: 3Answers: 0
The singular function row().node():
http://datatables.net/reference/api/row%28%29.node%28%29
Does not return an API object, so you can't call to$() on it. Instead, one must call row().nodes().to$() (note the plural on node).
Example:
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I'm afraid I don't see why this is a bug. The documentation (which you linked to) notes that the
row().node()
method returns anode
and not a DataTables API instance. This is intended and expected (although I realise that it might have been more convenient to always return a jQuery object...).You could also use
$( table.row( ... ).node() )
.Allan
While that is true, it is a bit misleading that I have to use nodes() for the singular case. The other row functions don't work like that. Doesn't row().node() to get a single API instance make more sense than row().nodes()? Especially considering there is a rows().nodes().
rows().nodes()
must return a collection - be it an array or an array like object. It could (possibly should) return a jQuery object, but it returns an API instance like all other API methods that return a collection.row().node()
however does not need to return a collection - it gives access to a single entity only. So like the other DataTables API methods that return a single value it does not return an API instance. Consider for examplecolumn().visible()
- it returns a boolean.The difference between the singular and plural is a key item in the DataTables API - it is important to understand the difference between them.
Allan
The documentation I linked to has as an example:
This code does not work as of 1.10.7, since, as you noted, node() returns a node object, not a DataTables API instance. Specifically, one gets Type Error '.to$ is not a function'.
Maybe the example for row().node() needs to be changed.
Hi,
Thanks for pointing that out!
rows().node().to$()
will work, but using a singularrow()
will not work. I'll correct the example and deploy it to the site shortly!Regards,
Allan