paperclip and fancybox gem problems
I'm trying to use the Fancybox Gem in my rails app with paperclip.
Thumbnail and image link:
<div class="fancybox"> <%=link_to image_tag (image.url(:small)), image.url(:large) %></div>
jQuery files added via the gem instructions开发者_运维技巧 in my application.js:
//= require jquery
//= require fancybox
in controller_name.js
$(document).ready(function() {
$("a.fancybox").fancybox();
});
How do I make the link use Fancybox and not just go to the image?
Any help would be great!
I can see the problem here. You are initializing facybox for all links which have class facybox but you have applied the class to div. you can rewrite your html code as to apply the fancybox class to link:
<div >
<%=link_to(image_tag (image.url(:small)), image.url(:large),:class=>"fancybox") %>
</div>
keep your javascript code same as you mentioned here.
Hopefully this helps someone in the future a few minutes of searching... Here is how your link should look
<%=link_to image_tag(pic.avatar.url(:thumb)),pic.avatar.url(:original), class:"fancybox" %>
And you should also include *= require fancybox
in your Application.css/.scss
精彩评论