This pagination facilates retrieving of photos from database with AJAX.
1.Create partial in views.Add following code to it.
0), :update => “your div id“,
:url => {:action => :imgstrip, :id => post, :skip => ([0,skip.to_i-1].max) } if post.medias.size>4 –>
=0
break if (cnt+=1)==5
–>
0), :update => “your div id“,
:url => {:action => ‘action‘, :id => post, :skip => ([0,[skip.to_i+1,post.medias.size-4].min].max) }if post.medias.size>4 –>
Replace “post” with “your object“
2.To render template add following line to views
render :partial => ‘template‘, :locals => { :post => post, :skip => params[:skip] }
3.Add following in controller.rb
def action
post = Post.find params[:id]
render :partial => ‘template’ :locals => { :post => post, :skip => params[:skip] }
end
Replace ‘template’ with your view name.
This will show four photos after each scroll.
Thanks
Naveen Joshi
Tuesday, September 25, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment