how to make fnGetPosition work?
how to make fnGetPosition work?
Hi,
I kind of understand how datatables index DOM seperately from the real DOM, but I can't make fnGetPosition work.
My code is really simple. I have a table, I'm creating datatables on this table and then doing really simple test:
[code]
$('.invisible[rel="en_'+rel+'"]').parent().html('clicked');
console.log( oTable.fnGetPosition( $('.invisible[rel="en_'+rel+'"]').parent() ) );
[/code]
So the first line works perfectly, but the second returns always Error: nNode.nodeName is undefined.
Tried probably dozen of possibilities, changing class to ID, got rid of rel... still nothing. Even tried (found somewhere on forum):
[code]
console.log( oTable.fnGetPosition( oTable.$('.invisible[rel="en_'+rel+'"]').parent() ) );
[/code]
But still nothing... Any suggestions?
I kind of understand how datatables index DOM seperately from the real DOM, but I can't make fnGetPosition work.
My code is really simple. I have a table, I'm creating datatables on this table and then doing really simple test:
[code]
$('.invisible[rel="en_'+rel+'"]').parent().html('clicked');
console.log( oTable.fnGetPosition( $('.invisible[rel="en_'+rel+'"]').parent() ) );
[/code]
So the first line works perfectly, but the second returns always Error: nNode.nodeName is undefined.
Tried probably dozen of possibilities, changing class to ID, got rid of rel... still nothing. Even tried (found somewhere on forum):
[code]
console.log( oTable.fnGetPosition( oTable.$('.invisible[rel="en_'+rel+'"]').parent() ) );
[/code]
But still nothing... Any suggestions?
This discussion has been closed.
Replies
So to above code what you have to do is to add jQuery .get(0) method to the parent object and then pass it to fnGetPosition:
[code]
oTable.fnGetPosition( $('.invisible[rel="en_'+rel+'"]').parent().get(0);
[/code]
Good to hear you found a solution to this problem. The documentation does note that a node is expected, which is generally true for most DataTables API methods where it deals with elements, rather than jQuery objects: http://datatables.net/ref#fnGetPosition . However, this is certainly a limitation in DataTables and I will be looking at relaxing that constraint and allowing jQuery objects to be passed in - possibly v1.10 or v1.11.
Regards,
Allan