table click event fires sEcho number of times

table click event fires sEcho number of times

FredFlintstoneFredFlintstone Posts: 24Questions: 0Answers: 0
edited January 2013 in General
again, apologies if i'm missing something. if i have a table of paged data and page back and forwards through it, the value of sEcho is incremented with every new page. if i then click on a row, my handler for that event, eg

[code]
"fnDrawCallback": function (oSettings) {
$(myTable).click(function (event) {
alert("W");
if ($(event.target.parentNode).hasClass('row_selected')) {
$(event.target.parentNode).removeClass('row_selected');
}
else {
$(event.target.parentNode).addClass('row_selected');
}
});
$(myTable.fnGetNodes()).dblclick(function () {
var iPos = myTable.fnGetPosition(this);
var aData = oSettings.aoData[iPos]._aData;
window.location.href("/myTable/" + aData.myTableId);
});
},

[/code]

fires sEcho times. is this behaviour by design? seems a tad inefficient and i'm sure i'm missing something? thanks.

Replies

  • FredFlintstoneFredFlintstone Posts: 24Questions: 0Answers: 0
    i think allan you might have answered this in another post?

    http://datatables.net/forums/discussion/8704/ajax-datasource-and-and-single-row-select/p1

    sorry for not searching more thoroughly...
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Yup - same thing here - the event is being added on every draw. Visual Event can be useful when debugging these things: http://sprymedia.co.uk/article/Visual+Event+2 .

    Having said that, since you are using static events, I actually would have expected your code above to work. live / delicate events would certainly suffer, and non-server-side processing tables, but a table with server-side processing enabled, should actually be able to handle that (although it would leak RAM since you aren't unbinding the jQuery event handlers).

    Allan
This discussion has been closed.