Pagination problem, function works only on the first page

Pagination problem, function works only on the first page

agn0sticagn0stic Posts: 2Questions: 0Answers: 0
edited January 2010 in General
Hi,
First of all, thank you for DataTables. I love it. But to the point :)
I noticed that when i try to call a function
[code]$("#table tbody tr").click( function () {
trNumber = oTable.fnGetPosition( this );
alert("tr #: "+trNumber);
});[/code]
it works only on the first 10 rows (by default 10 rows are shown on 1 page). When I click next page this function doesn't work, nor when I change to display more than 10 rows at once. I was looking for that for couple hours but can't find answer. Hope that you can help me, thank you :)

Replies

  • shauntainshauntain Posts: 6Questions: 0Answers: 0
    I am having this same problem as well... Depending on your application you might have luck with using fnRowCallback to add the click listeners. What I tried is in my post here... http://datatables.net/forums/comments.php?DiscussionID=1125&page=1#Item_1... it didn't work it my application but you might be using datatables differently
  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi,

    Please have a look at the two event application examples:

    http://datatables.net/examples/advanced_init/events_pre_init.html
    http://datatables.net/examples/advanced_init/events_post_init.html

    Regards,
    Allan
  • agn0sticagn0stic Posts: 2Questions: 0Answers: 0
    Thanks for the tip. It was caused by the wrong order of code. I was initializing table first, then adding the function when it should have been the other way around.
    Now everything works, thank you.
This discussion has been closed.