Need to fire function after page event

Need to fire function after page event

DavidBoomerDavidBoomer Posts: 21Questions: 0Answers: 0
edited September 2012 in DataTables 1.8
The page event in the following code snippet fires before the paging event has actually occurred.

$('#dataTableID').live('page', function () { logWhateverShowsInCell2(); });

Is there a way to attach an event listener for after the paging?

FWIW, "fnDrawCallback" : logWhateverShowsInCell2(), ... only fires for the initial loading of the dataTable, not on subsequent events like paging, sorting, filtering, etc...

Replies

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Unfortunately not at the moment. The closest I suppose would be to have the page event set a flag which your fnDrawCallback function (or a 'draw' event listener) would check for and then take action on, clearing the flag.

    Allan
  • DavidBoomerDavidBoomer Posts: 21Questions: 0Answers: 0
    thanks for your response, allan. is there some way to attach a click event to the pagination container (span, i'm guessing)? or would that still occur after the page event? i'm asking because a click event attached to $("#tableID thead") etc.. occurred after the sort, and i was able to grab the new cell2 contant.
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    > is there some way to attach a click event to the pagination container (span, i'm guessing)?

    Sure just add it in the same way you would add any jQuery event listener. The exact order would depend upon the order the events are added and the sequence in which jQuery fires the events. I suspect if you add it after the table has been initialised it should work okay.

    Allan
  • DavidBoomerDavidBoomer Posts: 21Questions: 0Answers: 0
    edited September 2012
    Well, I have partial success here. I am using full_numbers as the pagination type, and if I create this event listener $('#dataTableID_paginate').live('click', function(){ logWhateverShowsInCell2(); }); then the function is called when the first, previous, next, and last buttons are clicked, but not when the number buttons are clicked. I see in firebug that "dataTableID_paginate" is a div and that the number buttons are anchor tags in a span and neither of these have ids. Can anyone show me how to get a reference to the buttons?
  • grahampcharlesgrahampcharles Posts: 20Questions: 1Answers: 0
    You don't need IDs to attach an event handler -- use

    $("#dataTableID_paginate").on("click", "a", function() { alert("clicked") });
This discussion has been closed.