[英]To hide "..." used in the will_paginate function on Rails
由於值的數量,我正在使用 will_paginate,但我不知道如何隱藏“...”部分和后面的頁碼。 這是我目前擁有的:
這就是我想要的:
< 1 2 3 4 >
單擊下一步會給我 < 2 3 4 5 > (注意在兩者中,我們沒有看到“..”后跟 95 96 97。)
知道如何做到這一點嗎? 這是相關的 HTML:
<div class="pagination full">
<span class="previous_page disabled">< 前へ</span>
<em class="current">1</em>
<a rel="next" href="/student/search?page=2">2</a>
<a href="/student/search?page=3">3</a>
<a href="/student/search?page=4">4</a>
<a href="/student/search?page=5">5</a>
<a href="/student/search?page=6">6</a>
<a href="/student/search?page=7">7</a>
<a href="/student/search?page=8">8</a>
<a href="/student/search?page=9">9</a>
<span class="gap">…</span>
<a href="/student/search?page=95">95</a>
<a href="/student/search?page=96">96</a>
<a href="/student/search?page=97">97</a>
<a class="next_page" rel="next" href="/student/search?page=2">次へ ></a>
</div>
謝謝!
您需要為will_paginate
制作一個自定義渲染器。 will_paginate
助手接受這樣的參數renderer
:
<%= will_paginate(@users, :renderer => UserPaginationRenderer) %>
你只需要自己實現UserPaginationRenderer
,使用你自己的規則,比如只顯示 4 個鏈接等等。 有很多關於此的信息和文章:
https://thewebfellas.com/blog/roll-your-own-pagination-links-with-will_pagination
https://www.tachyonstemplates.com/2017/custom-renderer-will-paginate/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.