Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

My picture hides after closing the fancybox window

I'm trying to use fancyBox and I wonder why when I close the fancyBox window, my element gets a "display:none;" style. Is there any solution to avoid this ?

My html file includes :

<script type="text/javascript" src="../js/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" href="../css/jquery.fancybox.css" type="text/css" media="screen" />

The target element is this:

<div id="cadre" class="planche"><a id="inline" href="#photo"><img src="../img/new/img/1_ADELE_HAENEL_Actress-H.jpg" alt="ADELE HAENEL" id="photo"></a></div>

My Fancybox js is:

$(document).ready(function() {

    /* This is basic - uses default settings */

    $("a#single_image").fancybox();

    /* Using custom settings */

    $("a#inline").fancybox({
        'hideOnContentClick': false
    });

    /* Apply fancybox to multiple items */

    $("a.group").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });

});
like image 989
Fabrice Chapot Avatar asked Dec 27 '12 14:12

Fabrice Chapot


People also ask

How do I open fancyBox on button click?

jQuery(document). ready(function($) { $('button'). on('click', function() { $. fancybox(); }); });

What is data fancyBox?

FancyBox is a tool for displaying images, html content and multi-media in a Mac-style "lightbox" that floats overtop of web page. It was built using the jQuery library.


2 Answers

I had the same problem and the solution was to to populate the href attribute of the a element with a valid href

like image 81
emanuel.virca Avatar answered Sep 26 '22 14:09

emanuel.virca


Add a valid href tag to the a element. Below is a simple example for the same. I faced the same issue and fixed with that.

<a class="fancybox" href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/></a>

Then call the fancybox.

$(".fancybox").fancybox({});

JsFiddle demo example

http://jsfiddle.net/FM82s/

like image 43
Krishnadas PC Avatar answered Sep 22 '22 14:09

Krishnadas PC