问题
Does anyone know of a good lightbox plugin for rails? I found redbox but it seems to be out of development.
Thanks!
-Elliot
回答1:
I just use the regular Lightbox 2. Include all the appropriate javascript and stylesheets then :rel => "lightbox" on your links.
回答2:
Here is example how to easily use lightbox in rails (v4 in my case):
1. Download from site: http://lokeshdhakar.com/projects/lightbox2/
2. Copy lightbox.js to app/assets/javascripts
3. Copy lightbox.css to app/assets/stylesheets
4. Rename lightbox.css to lightbox.css.scss.erb
5. Copy four img's to app/assets/images
6. Edit lightbox.css.scss.erb:
- All image paths replace with:
<%=image_path "close.png"%>
with proper image name.
Add a data-lightbox attribute to any image link to activate Lightbox. For the value of the attribute, use a unique name for each image. For example:
<a href="img/image-1.jpg" data-lightbox="image-1" data-title="My caption">Image #1</a>
Thats all.
回答3:
Is there anything wrong with the jQuery version?
Jquery on Rails
http://railstips.org/2008/11/20/jquery-on-rails-why-bother
回答4:
You can try lightbox2, don't know if there is any rails plugin to use it, but writing some helper functions shouldn't be that difficult.
回答5:
You can use http://github.com/Lipsiasoft/lightbox
回答6:
I would recommend rlightbox. It is a jquery UI plugin. It can be used for photos and videos and the documentation is pretty good
回答7:
I wrote my own Rails wrapper to use Lightbox inside your existing Rails application.
Github: https://github.com/vernondegoede/lightbox-rails
来源:https://stackoverflow.com/questions/1280793/lightbox-for-rails