script/plugin install svn://errtheblog.com/svn/plugins/will_paginate Model -> Controller
[url]http://hideto.iteye.com/blog/108118[/url]
Ajax
[url]http://www.letrails.cn/archives/07-10-25-ajax-will-paginate[/url]
def will_paginate_remote(paginator, options={})
update = options.delete(:update)
url = options.delete(:url)
str = will_paginate(paginator, options)
if str != nil
str.gsub(/href="(.*?)"/) do
"href=\"#\" onclick=\"new Ajax.Updater('" + update + "', '" + (url ? url + $1.sub(/[^\?]*/, '') : $1) +
"', {asynchronous:true, evalScripts:true, method:'get',}); return false;\""
end
end
end
will_paginate_remote(feeds, :param_name => 'feed_page', :update=>'feed-list', :url=>"/feeds/list")
本文介绍了一种使用Rails框架中的Will_Paginate插件实现远程加载分页内容的方法。通过自定义的will_paginate_remote函数,可以为分页链接添加Ajax点击事件,使得页面在切换分页时无需重新加载整个页面,而是仅更新指定的部分内容。
1171

被折叠的 条评论
为什么被折叠?



