Kaminari非常适合创建类似Twitter的分页:
=link_to_next_page(@results, t('kaminari.next'), :remote => true, :class => 'kaminari-next', :rel => 'next')然而,有谁有办法让它支持块呢?我想添加一个非常棒的字体图标:
=link_to_next_page @results, :rel => 'next', :remote => true, :class => 'kaminari-next' do
%i.icon-chevron-down.icon-2x
%br
=raw(t 'kaminari.next')这似乎不管用。
发布于 2013-06-28 23:39:06
我通过查看source code of Kaminari找到了该方法的定义。
# A simple "Twitter like" pagination link that creates a link to the next page.
#
# ==== Examples
# Basic usage:
#
# <%= link_to_next_page @items, 'Next Page' %>
#
# Ajax:
#
# <%= link_to_next_page @items, 'Next Page', :remote => true %>
#
# By default, it renders nothing if there are no more results on the next page.
# You can customize this output by passing a block.
#
# <%= link_to_next_page @users, 'Next Page' do %>
# <span>No More Pages</span>
# <% end %>
def link_to_next_page(scope, name, options = {}, &block)
params = options.delete(:params) || {}
param_name = options.delete(:param_name) || Kaminari.config.param_name
link_to_unless scope.last_page?, name, params.merge(param_name => (scope.current_page + 1)), options.reverse_merge(:rel => 'next') do
block.call if block
end
end这说明当您传递一个块时,块内容是在下一页上没有更多结果时显示的内容。因此,它似乎不支持您试图实现的目标。也许您可以手动添加想要显示的内容,然后将该代码转换为部分代码。
https://stackoverflow.com/questions/17368033
复制相似问题