Rails Kaminari - How to Show Pagination Links at the Top and Bottom of the Page?

StackOverflow https://stackoverflow.com/questions/17895892

  •  04-06-2022
  •  | 
  •  

سؤال

The title pretty much says it all. I don't want the user to have to scroll back to the top before they can select the next page.

I can pull out the query string and write my own logic to build the appropriate links, but I can't believe this isn't built in.

هل كانت مفيدة؟

المحلول

So far, this is the quickest way I've seen to do it.

Kaminari creates this already at the top of the page:

<nav class="pagination">

So I added, at the bottom of the page:

<span class="bottomPageLinks"></span>

Then added the following javascript to the page:

$(function(){
    $('.pagination').clone().appendTo('.bottomPageLinks');
});

If someone knows a native Kaminari route that avoids the added complication, I'd still like to know about that.

نصائح أخرى

<%= paginate @your_model %>

Should go at the bottom, outside of your ul/form.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top