clde clde - 1 month ago 7x
jQuery Question

DataTables: Pressing enter key in order to use pagination with a textbox

I have succesfully implemented the DataTables (version 1.10+) pagination plugin with textbox but I would like to allow the user to first enter a page number and then to press the enter key. By default, instantly the user is taken to the page but, as stated above, I would like to allow to write first a number with in the textbox and then jump to the page by using the enter key. Any ideas on how to do this?


You can use the input pagination plugin :

var table = $('#example').DataTable({
   pagingType: "input"

example ->

It does not support "jump to the page by using the enter key" out of the box, but you can easily refactor the code. Look at the source around line #164 (in function $(nInput).keyup(function (e) {.. ). Change



if (e.which === 13) fnCallbackDraw(oSettings);

That should be it. Have not tested it but this is certainly the way to go.