Selecting row (tr) after fnAddRow() problem

Selecting row (tr) after fnAddRow() problem

recoilrecoil Posts: 2Questions: 0Answers: 0
edited July 2011 in General
Hi,

I'm using this code for selecting current row in table

[code]
$("#routingTable tr").click(function(event) {
currRoutePos = routingTable.fnGetPosition(this); // current selected row position
currRouteData = routingTable.fnGetData(currRoutePos);
$("#routingTable tr td").removeClass('selected');
$(this).find("td").addClass('selected');
});
[/code]

It works just fine, but when I add a new row in table...

[code]
routingTable.fnAddData([
name.val(),
nenabled,
destination.val(),
netmask.val(),
gateway.val()
]);
[/code]

That row cannot be selected? Any suggestions?

Jan

Replies

  • recoilrecoil Posts: 2Questions: 0Answers: 0
    Hi, solved with

    [code]
    $("#routingTable tr").live('click', function() {
    [/code]

    instead of

    [code]
    $("#routingTable tr").click(function(event) {
    [/code]
  • BobRBobR Posts: 7Questions: 0Answers: 0
    I'm looking for examples of this mysterious fnAddRow. This thread mentions it, but uses fnAddData in the example. Is there such a method?
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    I suspect that was a typo given that the code from recoil uses fnAddData. There is fnAddTr which is available as a plug-in ( http://datatables.net/plug-ins/api#fnAddTr ) which might do what you are looking for?

    Allan
This discussion has been closed.