Changing page or length of the table

Changing page or length of the table

dimapdimap Posts: 3Questions: 0Answers: 0
edited November 2012 in General
I'm fairly new with DataTables, please bear with me :)

My table has links in some of the table cells. I catch clicks on them and do some stuff:
[code]
$('a.test').click( function () {
console.log("clicked");
});
[/code]
Everything is good until I change the length of the table or go to the next page.
The links in rows which weren't originally displayed in the first page can't be captured with jQuery anymore.
Looking into the html with firebug everything looks ok, the rows and links are there, but they can't be selected.

I must be missing some very basic here...
Does something need to be refreshed or reloaded when pagination or length of the table gets changed?

Thank you in advance!

Replies

  • dimapdimap Posts: 3Questions: 0Answers: 0
    Found the solution:

    $('a.test').live('click', function() {
    console.log("clicked");
    });

    sorry for the off topic, it's pretty basic jQuery stuff after all
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    `on` is now the recommended way to do this kind of thing in jQuery:

    [code]
    $('tbody').on( 'click', 'a.test', function () {
    ...
    } );
    [/code]

    for example. `live` is decremented in the jQuery API. I'll be updated the FAQs and all examples on this site soon.

    Allan
  • dimapdimap Posts: 3Questions: 0Answers: 0
    Thank you Allan, that makes sense
This discussion has been closed.