Need help in Ajax Pagination

hi All,

i wants to implement ajax pagination but i am facing a lot of
problem , i found i lots of links on google but their is no
explanation like what object we have to pass and condition can any
body help me out in this concern pls i need your help as soon as
possible

thanks
sachin

[email protected] wrote:

hi All,

i wants to implement ajax pagination but i am facing a lot of
problem , i found i lots of links on google but their is no
explanation like what object we have to pass and condition can any
body help me out in this concern pls i need your help as soon as
possible

thanks
sachin

HI,

With normal pagination code in controller you can use this code to
perform pagination using Ajax.
In following code use proper action name from controller in
which you have done the pagination.

<%if @photo_pages.current.previous%>
<%= link_to_remote (“previous”,
:url=>{:action=>params[:redirect_action], :page
=>@photo_pages.current.previous,:redirect_action=>params[:redirect_action],:id=>params[:id]})%>
<%end%>

<%if @photo_pages.current.next%>
<%= link_to_remote (“next”, :url=>{:action=>params[:redirect_action],
:page =>
@photo_pages.current.next,:redirect_action=>params[:redirect_action],:id=>params[:id]})%>
<%end%>

Regards,
kiran

R U using will_paginate?

Sijo Kg wrote:

R U using will_paginate?

Hi,
I am using normal pagination code in controller as

@photo_pages ,@photos = paginate_collection @profile_user,:per_page =>
16,:page => @params[:page]

and in view using the code above specified.

Regards,
kiran

Hi
Add the following code to view_helpers.rb .The file is in
vendor/plugins/will_paginate/lib/will_paginate

def page_link_or_span(page, span_class = ‘current’, text = nil)
text ||= page.to_s
if page and page != current_page
if update = @options[:update]
@template.link_to_remote text, :update => update, :url =>
url_options(page)
else
@template.link_to text, url_options(page)
end
else
@template.content_tag :span, text, :class => span_class
end

Then for ajax pagination in view do like
<%= will_paginate @thecollectionyouwanttopaginate, :update=>‘div’,
:params=>{:controller=>‘controller_name’,:action=>‘action_name’,:any_additional_parameters=>@any_additional_parameters},
:container => false %>

And for normal pagination do what you are currenly doing

Sijo