You need to create custom renderer but currently available posts do not work well.
- Rails3 and will_paginate, Doing easy remote links – Rails3 Tricks #02
- Roll your own pagination links with will_paginate
I have solved this problem.
lib/remote_pagination_list_link_renderer.rb
class RemotePaginationListLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
private
# :remote => true
def link(text, target, attributes = {})
if target.is_a? Fixnum
attributes[:rel] = rel_value(target)
target = url(target)
end
attributes[:href] = target
attributes["data-remote"] = true
attributes["data-method"] = :get
tag(:a, text, attributes)
end
end
Then, call will_paginate helper like below.
<%= will_paginate @posts, :renderer => RemotePaginationListLinkRenderer %>If you want to set this renderer as default, config/initializers/will_paginate.rb
# for :remote option WillPaginate::ViewHelpers.pagination_options[:renderer] = 'RemotePaginationListLinkRenderer'
0 件のコメント:
コメントを投稿