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')
这似乎不起作用。
答案 0 :(得分:0)
我通过查看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
这表明当您传递一个块时,块内容是在下一页上没有更多结果时显示的内容。所以它似乎不支持你想要实现的目标。也许您可以手动添加想要显示的内容,然后将该代码转换为部分代码。