RoR & Lightbox

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.

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/

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

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.

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 :slight_smile:

Let me know how it goes.

–hax

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

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs