Lightbox in rails

Using a lightbox in rails is just a few steps.

Download lightbox.js and lightbox.css (or) control.modal.js and control_modal.css, which will be available if you search in any search engine. Copy the js file to your javascripts folder in the app and copy the css file to your stylesheets folder.

Then do the following code in your view file

<%= javascript_include_tag ‘prototype.js’, ‘lightbox.js’%>
<%= stylesheet_link_tag ‘lightbox’%>

<span id=”lightbox”><a id=”call” href=”<%= new_personal_path %>”>Click Here to Add a New Employee’s Personal Detail</a></span>
<script>new lightbox($(‘call’), {className:’lightbox_container’});</script>

if you use control.modal.js instead of lightbox.js then do this

<%= javascript_include_tag ‘prototype.js’, ‘control.modal.js’%>
<%= stylesheet_link_tag ‘control_modal’%>

<span id=”Control.Modal”><a id=”call” href=”<%= new_personal_path %>”>Click Here to Add a New Employee’s Personal Detail</a></span>
<script>new Control.Modal($(‘call’), {className:’lightbox_container’});</script>

Advertisements

2 thoughts on “Lightbox in rails”

  1. Thanks for this blog. Its really helped me. One thing is, it is better if you include the link to download lightbox.js and lightbox.css. Thanks again……………

Comments are closed.