Setting page jumps to first page only?

Setting page jumps to first page only?

fuenfundachtzigfuenfundachtzig Posts: 2Questions: 1Answers: 0
edited August 2015 in Free community support

After first posting my question here http://datatables.net/reference/api/page() , just to find out that it would never be shown, I'll ask here again:

I've tried to write some code so that you can use the left and right arrow keys to switch the page of the table being displayed:

    $(document).keypress(function (e) {
      if (e.keyCode == 37) {
        table.page( 'previous' ).draw( 'page' );
      }
    });
    $(document).keypress(function (e) {
      if (e.keyCode == 39) {
        table.page( 'next' ).draw( 'page' );
      }
    });

However, it always goes to the first page, no matter whether I press left or right. Is my use of the page() function wrong?

(I am using 1.10.7.)

This question has an accepted answers - jump to answer

Answers

  • fuenfundachtzigfuenfundachtzig Posts: 2Questions: 1Answers: 0
    edited August 2015

    I solved it by passing false to the draw function.

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin
    Answer ✓

    You use is correct, but passing a string into the draw() method requires DataTables 1.10.8 or newer. It looks like this didn't make it into the documentation. I'll add it now and push an update to the site shortly. Thanks for the feedback.

    Allan

This discussion has been closed.