2013-06-28 49 views
1

雷是偉大的創造類似Twitter的分頁:Kaminari支持塊?

=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

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

這表明,當您傳遞一個塊時,塊內容是在下一頁沒有更多結果時顯示的內容。所以它似乎不支持你想要達到的目標。也許你可以添加你想要手動顯示的內容,然後將該代碼轉換爲部分內容。