combining features: ajax + click handling

combining features: ajax + click handling

NeilForsythNeilForsyth Posts: 1Questions: 0Answers: 0
edited March 2009 in General
I'm probably missing a basic datatables (or jquery) concept here, but after loading data via ajax, my click handler doesn't work:

$(document).ready(function() {
$('#tblsearch').dataTable( {
"bProcessing": true,
"sAjaxSource": 'list-searchable.json.php',
"aoColumns": [
/* Country */ null,
/* State */ null,
/* City */ null,
/* Name */ null,
/* Phone */ null,
/* Model */ null
$('#tblsearch tr').click( function () {
alert("you clicked");
if ( $(this).hasClass('row_selected') )

The alert() is never fired, let alone the row_selected classes. Eventually i'll want to take this further this by manipulating other items on the page depending on the selected row(s) from the DataTable.


  • allanallan Posts: 57,236Questions: 1Answers: 9,113 Site admin

    It's slightly odd that none of the rows would have a click handler on them (I would have expected some, but not all would from that). However, what I think you are looking for is shown in the adding event after initialisation example:

    $( oTable.fnGetNodes() ).click( function () {
    /* whatever */
    } );

    should do it for you.

  • zygimantaszygimantas Posts: 33Questions: 0Answers: 0
    NeilForsyth, have you tried to bind event by using new JQuery "live" function? (
This discussion has been closed.