0

数字の 1、2、3 ではなく、点線の画像へのリンクのページネーションをカスタマイズしたいと考えています。ページネーション クラスの css をカスタマイズしようとしましたが、うまくいきませんでした。リンク形式の下に貼り付けます。

(既存) 前へ 1 2 3 次へ

(実装する必要があります) . . . . . . .

4

1 に答える 1

0

この質問が古いことは承知していますが、まだ回答が必要な場合があります。これはおそらく良い出発点です。次の内容で app/helpers/will_paginate_helper.rb などのヘルパーを作成します。

module WillPaginateHelper
  class DottedLinkRenderer < WillPaginate::ActionView::LinkRenderer
    protected
    def link(text, target, attributes = {})
      if target.is_a? Fixnum
        attributes[:rel] = rel_value(target)
        target = url(target)
      end
      attributes[:href] = target
      tag(:a, ".", attributes)
    end
  end

  def dotted_will_paginate(collection, options = {})
    will_paginate(collection, options.merge(:renderer => WillPaginateHelper::DottedLinkRenderer))
  end
end

次に、ビューで次を使用します。

<%= dotted_will_paginate @posts %>

これは基本的に、元のリンクレンダラーに基づくカスタム リンクレンダラーです。

于 2012-12-20T22:00:19.663 に答える