table.row(this).data on click of the row is now working the second time

table.row(this).data on click of the row is now working the second time

srinivasj2016srinivasj2016 Posts: 2Questions: 1Answers: 1
edited January 2016 in Free community support

Hi,
please find my code :

var weekTable = $('#jobs').DataTable({
        "data": data.data,   // Please assume data is defined                    
        "columnDefs": [{
                          "targets": [2],
                          "visible": true
                          //"searchable": false
                      }]
    });

 $('#jobs tbody').on('click', 'tr', function (i,val) {
console.log(weekTable.row( this ).data());
});

I could only fetch the data only for the first time.

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Could you link to a test page showing the issue (per the forum rules). The code you have above looks like it should work for all rows in the table as far as I can see.

    Allan

  • srinivasj2016srinivasj2016 Posts: 2Questions: 1Answers: 1
    Answer ✓

    Sorry Allan for not linking the page. Actually, adding $('#jobs tbody').on('click', 'tr', function (i,val) { // code });
    worked for me. Now I am getting row data on every click. I see more of the issue on the way jquery is been used & not the datatable. Thank you very much for the quick response.

This discussion has been closed.