Row click not firing off after Sort/Search/Next Page

Row click not firing off after Sort/Search/Next Page

gdawgrancidgdawgrancid Posts: 2Questions: 0Answers: 0
edited August 2012 in DataTables 1.9
I have a table that uses sorting and a tr click listener. It works fine at first, but whenever I try to sort, search, or go to the next page, I can no longer select a row. It only highlights the text in whatever table cell I'm clicking on. Do these things just not work well together or is it something on my side that could be causing this?

Here is the code I am using for my datatable:
[code]
var oTable=$('#OrderHistory').dataTable( {
"bAutoWidth": false,
"bJQueryUI":true,
"sPaginationType":"full_numbers",
"aaData": aDataSet,
"iDisplayLength": 25,
"oLanguage": {
"sLengthMenu": 'Display '+
'10'+
'25'+
'50'+
'100'+
'200'+
'All'+
' records'
},
"aoColumns": [
{ "sTitle": "Customer Name","sWidth":"30%" },
{ "sTitle": "Manufacturer","sWidth":"25%"},
{ "sTitle": "Order Date","sWidth":"15%" },
{ "sTitle": "PO","sWidth":"15%" },
{ "sTitle": "Order Code","sWidth":"15%" },
{ "sTitle": "OrderID","sWidth":"0%", "sClass":"orderID"},
]
} );

$("#OrderHistory tbody tr").click( function( e ) {
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
loadOrderHistory(this);
}
else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});[/code]

Here is my debugging link http://debug.datatables.net/usozes

Replies

  • gdawgrancidgdawgrancid Posts: 2Questions: 0Answers: 0
    Got it figured out. Needed to switch the .click event to be .live('click', function(e){....
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    That's perfect, I was having the same problem. But my concern is .live() is deprecated from jquery 1.7. I am not sure if there is any alternative to this.
This discussion has been closed.