浏览 3413 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-01
在ViewHelper.rb中 @@pagination_options = { :class => 'pagination', :prev_label => '« Previous', :next_label => 'Next »', :inner_window => 4, # links around the current page :outer_window => 1, # links around beginning and end :separator => ' ', # single space is friendly to spiders and non-graphic browsers :param_name => :page, :params => nil, :renderer => 'WillPaginate::LinkRenderer', :page_links => true, :container => true } 增加update 修改为: @@pagination_options = { :class => 'pagination', :prev_label => '« Previous', :next_label => 'Next »', :inner_window => 4, # links around the current page :outer_window => 1, # links around beginning and end :separator => ' ', # single space is friendly to spiders and non-graphic browsers :param_name => :page, :params => nil, :renderer => 'WillPaginate::LinkRenderer', :page_links => true, :container => true, :update => nil } page_link_or_span方法修改为: def page_link_or_span(page, span_class = 'current', text = nil) text ||= page.to_s if page and page != current_page if(@options[:update] != nil) @template.link_to_remote text, :url=>url_options(page),:update=>@options[:update] else @template.link_to text, url_options(page) end else @template.content_tag :span, text, :class => span_class end end 在页面上:普通链接方式: <%=will_paginate @users, {:class=>'pagination', :prev_label => '上一页',:next_label => '下一页'}%> ajax方式: <%=will_paginate @users, {:class=>'pagination', :prev_label => '上一页',:next_label => '下一页',:update => 'content'}%> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-05-01
will_paginate接受一个renderer参数,默认是WillPaginate::LinkRenderer,更好的做法是subclass一个AjaxLinkRenderer,这样不需要修改它的源代码,在做plugin升级的时候会很方便。
|
|
返回顶楼 | |
发表时间:2008-05-01
Quake Wang 写道 will_paginate接受一个renderer参数,默认是WillPaginate::LinkRenderer,更好的做法是subclass一个AjaxLinkRenderer,这样不需要修改它的源代码,在做plugin升级的时候会很方便。
是这样的,之前没怎么仔细读源码,惭愧 |
|
返回顶楼 | |
发表时间:2008-05-01
AjaxLinkRenderer类:
class AjaxLinkRenderer < WillPaginate::LinkRenderer def page_link_or_span(page, span_class = 'current', text = nil) text ||= page.to_s if page and page != current_page @template.link_to_remote text, :url=>url_options(page),:update=>@options[:update] else @template.content_tag :span, text, :class => span_class end end end 页面: <%=will_paginate @users, {:class=>'pagination', :prev_label => '上一页', :next_label => '下一页', :renderer => 'AjaxLinkRenderer', :update => 'content'}%> |
|
返回顶楼 | |