Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom pagination, arrows instead of Next Previous

I'm using jQuery DataTables and I want to extend the default pagination to use buttons with arrows or images instead of Next Previous text links.

On script initialization I tried to use

    ...
     "oPaginate": {                       
             "sNext": '<i class="entypo-right-circled" ></i>',
             "sPrevious": '<i class="entypo-left-circled" class="Dia_pagination_ico" ></i>'
     },
    ...

but I still have default pagination like

enter image description here

like image 229
user1765862 Avatar asked Feb 03 '16 13:02

user1765862


1 Answers

You can customize the pagination button labels through language.paginate.next and language.paginate.previous.

$('#the_table').DataTable({
  language: {
    paginate: {
      next: '&#8594;', // or '→'
      previous: '&#8592;' // or '←' 
    }
  }
});

Because the values for next and previous can include markup, you can even use an image or a glyph icon font.

$('#the_table').DataTable({
  language: {
    paginate: {
      next: '<img src="path/to/arrow.png">',
      previous: '<i class="fa fa-fw fa-long-arrow-left">'  
    }
  }
});

If you want to include an arrow before or after the existing text, you can also use plain CSS:

.paginate_button.previous:before {
  content: '← ';
}

.paginate_button.next:after {
  content: ' →';
}
like image 60
twernt Avatar answered Nov 01 '22 03:11

twernt