修改will paginate支援ajax方式

2021-08-22 15:49:40 字數 796 閱讀 9657

網上關於will_paginate支援ajax的文章不少,可是看了一下,都比較舊了,在最新更新的will_paginate外掛程式下用不了,所以就自己改了一下

在viewhelper.rb中

[code]

@@pagination_options =

[/code]

增加update 修改為:

[code]

@@pagination_options =

[/code]

page_link_or_span方法修改為:

[code]

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)

endelse

@template.content_tag :span, text, :class => span_class

endend

[/code]

[code]

[/code]

ajax方式:

[code]

[/code]

應用WillPaginate分頁

rails sqlruby willpaginate這個外掛程式很棒,以至於其取代了rails中原有的paginate方法,雖然看上其很簡單,其實還是有不少技巧的,本篇用來記錄我遇到的或者使用到的一些tips。1.直接使用paginate 這個比較簡單,也是使用的最多的,如下 ruby defsel...

應用WillPaginate分頁

willpaginate這個外掛程式很棒,以至於其取代了rails中原有的paginate方法,雖然看上其很簡單,其實還是有不少技巧的,本篇用來記錄我遇到的或者使用到的一些tips。1.直接使用paginate 這個比較簡單,也是使用的最多的,如下 ruby defself get all item...

支 zi 持 ci 修改的莫隊演算法

相信大家對o n32 離線解決序列問題莫隊演算法都不陌生,在這裡我要介紹一下能夠茲瓷修改操作的莫隊演算法。關於基本的不帶修改的莫隊演算法,參考cty的部落格 分塊大小 s 為n2 3,那麼我們就有n1 3 塊。原本的莫隊關鍵字只有兩個,乙個是左邊界,乙個是右邊界。而帶修改莫隊要再加上一維 在第幾個操...