1

I am using Datatables and I am using this code to get clickable rows, called from fnInitComplete:

function createClickableRowsAllTickets() {
      $(allTable.fnGetNodes()).click( function() {
           alert('row clicked');        
      });
}

This works fine. However when I use fnReloadAjax to update the table the row clicks are no longer bound.

I tried to call the function once again on the callback of the fnReloadAjax but it doesn't work:

$("#alltickets input[type=checkbox]").click(function() {
    allTable.fnReloadAjax('get_tickets', createClickableRowsAllTickets());
});

What am I doing wrong?

4

1 回答 1

0

问题解决了。

代码应该是:

$("#alltickets input[type=checkbox]").click(function() {
allTable.fnReloadAjax('get_tickets', function() { createClickableRowsAllTickets();},    null);
});

代替:

$("#alltickets input[type=checkbox]").click(function() {
allTable.fnReloadAjax('get_tickets', createClickableRowsAllTickets());
});

注意回调参数中 function() 的使用。

于 2012-09-13T19:36:25.587 回答