Articles tagged “will_paginate”
Implementing an image gallery using facebox and will_paginate
On VisitaCSA we’re using defunkt’s facebox to show places images at large. Facebox is a great general-purpose lightbox, because it is fast, stable, is based on jQuery and has got a really clean API.
But we needed more than a simple display lightbox, because we wanted our users to navigate easily between all images, possibly without modifying facebox at all. The solution turned out to be pretty simple, thanks also to the will_paginate plugin we were already using. It all burns out to have:
- A Photo model, instrumented with the
has_attachmentmethod - Resource routes for photos (
map.resources :photos, :only => :showinconfig/routes.rb) - A
showcontroller method in thePhotosControllerthat calls.paginatewith a:per_pageargument of 1 - An HTML view for the photo resource, that has pagination controls using the
will_paginatehelper - Some jQuery code hooks onto the pagination links and make the browser load via AJAX the next photo directly into the facebox.


