I am using DataTables plugin with hidden rows, when using pagination, my click event fails without console error.
This is the function:
$(document).ready(function() {
$('#datatable tbody td a').on('click', function (e) {
e.preventDefault();
var nTr = $(this).parents('tr')[0];
if ( oTable.fnIsOpen(nTr) ) {
/* This row is already open - close it */
$(this).addClass('glyphicon-arrow-down');
$(this).removeClass('glyphicon-arrow-up');
oTable.fnClose( nTr );
} else {
/* Open this row */
$(this).addClass('glyphicon-arrow-up');
$(this).removeClass('glyphicon-arrow-down');
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
});
});
As you can see i am using delegation, but the function is wrapped in a ready function. I'm certain this is the problem. How do i fix this?
The above question was asked in error, please see my comment under the answer.