1

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')

这似乎不起作用。

4

1 回答 1

1

我通过查看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

这表明当您传递一个块时,块内容是在下一页没有更多结果时显示的内容。所以它似乎不支持你想要实现的目标。也许您可以手动添加您想要显示的内容,然后将该代码转换为部分代码。

于 2013-06-28T15:39:05.517 回答