Subodh Nijsure
Subodh Nijsure

Reputation: 3453

DataTable jquery selectors not firing

I have following code to handle clicks on row or individual cells.

$(document).ready(function() {
    var JSON_URL = '{% url "technician_activity" %}';
    var oTable = $('#technician_activity').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": JSON_URL ,
        "jQueryUI":       true
    } );
    alert("Without this alert selectors don't work? oTable = " + oTable);
    oTable.$('tr').click( function () {
       var data = oTable.fnGetData( this );
       alert("Column " + data);
    });
    oTable.$('td').click( function () {
       var data = oTable.fnGetData( this );
       alert("Cell " + data);
    });

});

One thing that puzzels me is without the first alert statement

alert("Without this alert selectors don't work? oTable = " + oTable);

selectors for tr and td don't work this is very puzzling to me -- what is the difference that this alert() is making?

Upvotes: 0

Views: 131

Answers (1)

Subodh Nijsure
Subodh Nijsure

Reputation: 3453

I am now using code as suggested here - http://www.datatables.net/examples/server_side/select_rows.html

But it still remains question as to why the in code I initially posted, with first alert() statement things work but they don't work when that alert statement is absent....

Just for curiosity sake would like to understand whats going on there in case someone has ideas.

Upvotes: 1

Related Questions