problem with pagination

problem with pagination

jeansonjeanson Posts: 9Questions: 0Answers: 0
edited March 2010 in General
Hi everybody,

I encountered a problem that i can't solve with the pagination :
I use the "sPaginationType": "full_numbers" so i get for 30 records 10 per page a pgination like :
First Previous 1 2 3 Next Last
I would like to put an alert when one of these buttons is clicked :
[code]
$('#the_table_paginate').bind("click", function () {
alert ('pagination');
});
[/code]
This works fine for First, Previous, Next, Last but not for 1, 2, 3 buttons.
I also tried $('.paginate_button'), $('span') with no success.

If someone has got an idea, please do not hesitate.
Thanks (and by the way, this tool is fantastic)

Replies

  • jeansonjeanson Posts: 9Questions: 0Answers: 0
    nobody can help me ??
  • dgtaylor22dgtaylor22 Posts: 16Questions: 0Answers: 0
    edited March 2010
    I actually came here looking for this solution. Luckily, I figured out the solution. Try this

    [code]
    $('#the_table_paginate').live("click", function () {
    alert ('pagination');
    });
    [/code]

    Notice the 'live' instead of 'bind'. The number buttons are created dynamically and the bind is getting lost in the shuffle.
  • dgtaylor22dgtaylor22 Posts: 16Questions: 0Answers: 0
    well, sorry if I got your hopes up. This may not work, but I think is a start. The actual problem may lie in the datatables source code. It appears that it stops the event propagation. I'm still learning about this, but I think this may be what is happening. If you look at the source code (1.6.2) lines 508-529, are where the number "links" are created.

    When I had it working on my end, I had modified the source code by removing all the "return false" code, so that click events would bubble up to other events. The other possibility is my jquery selector, but I'm leaning towards the event propagation since the first, previous, next, and last "links" work, but not the number "links".
  • jeansonjeanson Posts: 9Questions: 0Answers: 0
    Thanks for your answer.
    I don't want to go inside the source code because I'm not enough skilly for that.
    I'm still trying to find another way to bypass the problem
  • dgtaylor22dgtaylor22 Posts: 16Questions: 0Answers: 0
    I don't condone modifying the source either (especially as active as this project is), but I think it shows us why it isn't working. I ended up going to the 2 button (default) pagination.

    Hopefully Allan might chime in and let us know what is happening and/or why the event propagation is stopped for the pagination number buttons.
  • TomCTomC Posts: 43Questions: 0Answers: 0
    You should be able to hook stuff to anything via the jQuery selector if you use the fnInitComplete method to make sure that it runs after all the datatable work is done. I can't test this right now but I'm using that technique to do something similar in my project.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hmmm - this is an interesting one, and I'm afraid I don't have an answer at the moment. If you remove the 'return false' from fnClick in the update function - this should work fine. But it's not - and I can't for the life of me see why at the moment. There appears to be something in _fnDraw which is blocking it, or perhaps something it calls - but I can't see what it would be.

    I've updated Visual Event ( http://sprymedia.co.uk/article/Visual+Event ) to work with jQuery 1.4, to help with this, and while it has a bit (i.e. it looks like it should be working!) I still can't see it... A bit more work needed on this one. It's odd.

    Allan
  • dgtaylor22dgtaylor22 Posts: 16Questions: 0Answers: 0
    allan,
    Thanks for looking at this one. I couldn't figure out why removing the 'return false' didn't do it. So I also removed '.bind( 'mousedown', fnFalse ).bind( 'selectstart', fnFalse );' Line 528 in 1.6.2. Although I wasn't sure what implications this had, but maybe you can shed some light on why these are there as well. Thanks again.
  • mark.rogersmark.rogers Posts: 1Questions: 0Answers: 0
    Any update on this issue by chance? Just wondering if perhaps someone else found a solution to this problem.
This discussion has been closed.