首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kaminari支持块?

Kaminari支持块?
EN

Stack Overflow用户
提问于 2013-06-28 23:13:49
回答 1查看 415关注 0票数 1

Kaminari非常适合创建类似Twitter的分页:

代码语言:javascript
复制
=link_to_next_page(@results, t('kaminari.next'), :remote => true, :class => 'kaminari-next', :rel => 'next')

然而,有谁有办法让它支持块呢?我想添加一个非常棒的字体图标:

代码语言:javascript
复制
 =link_to_next_page @results, :rel => 'next', :remote => true, :class => 'kaminari-next' do
    %i.icon-chevron-down.icon-2x
    %br
    =raw(t 'kaminari.next')

这似乎不管用。

EN

回答 1

Stack Overflow用户

发布于 2013-06-28 23:39:06

我通过查看source code of Kaminari找到了该方法的定义。

代码语言:javascript
复制
# 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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17368033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档