# RoR & Lightbox

**URL:** <https://www.ruby-forum.com/t/ror-lightbox/100417>\
**Category:** Rails\
**Created:** [July 28, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/ror-lightbox/100417 "2006-07-28T21:02:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 28, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/1 "2006-07-28T21:02:12Z")

</div>

Has anybody else had a problem with using Lightbox in their RoR apps? I  
include all the necessary files in application.rhtml and then attempt to  
use  
the Lightbox functionality in pages and such. Nothing happens except  
that a  
new page opens up with the link to the image I was attempting to show  
with  
Lightbox. I’ve even gone so far as to strip out everything except the  
necessary Javascript files…still no luck. Any ideas?

TIA.

---

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 28, 2006, 10:05pm UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/2 "2006-07-28T22:05:44Z")

</div>

If memory serves, this was a problem with one of the included  
libraries (prototype??) I believe Lightbox uses an older version of  
the library. Try this instead:

[http://www.doknowevil.net/litebox/](http://www.doknowevil.net/litebox/)

Let me know how it goes. I abandoned the effort since it wasn’t  
something the user really wanted.

---

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 28, 2006, 11:56pm UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/3 "2006-07-28T23:56:25Z")

</div>

Yeah, this is a tricky one. The photo gallery tool Tableau uses this  
effect  
and it works perfect…and it’s a rails app. It’s open source, so I’m  
going  
to look through the code for it and see if that provides any clues.

-Tiffani A.B.

---

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 29, 2006, 2:07am UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/4 "2006-07-29T02:07:56Z")

</div>

I’ve used it with no problem at all and the latest version of prototype.

I think the only thing I had to do was go through the .js and.css and  
change some of the paths.

It’s not that hard to work through the javascript and understand what  
it all does.

It sounds like you’re not even including lightbox.js, or you’re not  
using rel=“lightbox”.  
Check the rendered html to make sure I’m wrong 🙂

Let me know how it goes.

–hax

---

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 29, 2006, 3:35am UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/5 "2006-07-29T03:35:51Z")

</div>

Hax, yeah, it sounds stupid, but it quite frustrating actually. I wish  
it was something as easy as rel=“lightbox”… but it isn’t.

---

<div class="post-metadata">

**Author:** ![Tiffani\_Ashley\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c37758/32.png) [@Tiffani\_Ashley\_B](https://www.ruby-forum.com/u/Tiffani_Ashley_B)\
**Post date:** [July 29, 2006, 4:26am UTC](https://www.ruby-forum.com/t/ror-lightbox/100417/6 "2006-07-29T04:26:44Z")

</div>

Well, after spending literally all day on this (it’s somehow an  
incredibly  
helpful feature for an app I’m building), I’ve gotten Lightbox (both the  
original version and v2) to cooperate with Rails. I somehow am swayed  
to  
believe that it was the version of Prototype I was using (1.5.0 rc0).  
After  
going back and substituting in 1.3.1 and then 1.4.0, things worked.  
Initially, the stylesheets were going haywire too (incredibly odd, eh?),  
but  
again, everything works now. Originally, once you clicked on the image,  
you  
would just be redirected to another page with that image on it.

Then, after more effort, I got the script to at least show the overlay,  
etc. But the graphic was shoved down to the bottom left of the screen  
with  
a huge gray area piled on top of it. A few hours later…after  
substituting  
other supposed exact copies of the Prototype and Lightbox scripts into  
place, I got it to work perfectly with the following rails code:

```
<%= link_to image_tag("thumb-1.jpg", :alt => "Greenery for

```

you!"),"/images/image-1.jpg", {:rel =\> “lightbox”, :title =\>  
“Greenery.”} %\>

That would just go wherever a Lightbox needs to appear. All the  
necessary  
.js files are included via a partial. Also, all the images that  
Lightbox 2  
needs are in “public/images.”

-Tiffani A.B.
