how to paginate combined with anchor id

前端 未结 1 1085
灰色年华
灰色年华 2021-01-02 10:54

I\'m very new to Ruby on Rails and learning while trying to fix some bugs on my company website. I\'m trying to paginate a collection of records combined with a particular a

相关标签:
1条回答
  • 2021-01-02 11:34

    I do not have direct experience with it. However, this link shows a way. I could not test but you can certainly do.

    <%= will_paginate @posts, :params => {:anchor => i} %>
    

    If this works, then you can utilize this way in your helper:

    def page_navigation_links(pages, param_name=:page)
      will_paginate(pages, :params => {:anchor => "#ANCHOR"}, :class => 'pagination', :inner_window => 2, :outer_window => 0, :renderer => BootstrapHelper::LinkRenderer, :previous_label => '&larr;'.html_safe, :next_label => '&rarr;'.html_safe, :param_name => param_name)
    end
    

    You can replace #ANCHOR as you need.

    0 讨论(0)
提交回复
热议问题