Kiranatama Staff
Knowledge


Update: Now this post using Rails 3.0.7 I found interesting pluginn for lightbox implementation with Facebook style, named Facebox. It allows us to use lightbox seamlessly in a Rails application.  You would use make a lightbox to display notice or error messages, form or even image without having to reload a page. Installation:
  1. Using Rails 3.0.7, the installation goes straight forward
    $ rails plugin install git://github.com/ihower/facebox_render.git
  2. You will need jQuery to use Facebox. I use jquery-rails when writing this post.
Usage: Add this in your application_controller.rb :
include FaceboxRender
In view code, when you want to call a lightbox :
facebox_link_to "Login", :url => login_url   
This is an example on how the code in a controller:
def login
  respond_to do |format|
    format.html
    format.js { render_to_facebox }
  end
end
That's it!. You just need to make a html.erb page as usual and call that page as a lightbox. It also support passing :action, :partial, :template, and :html parameter. Isn't that easy?