Eric
Eric

Reputation: 8078

fancybox event beforeClose not firing

I am using jquery fancybox and i want to hide an iframe containing a pdf file right before the fancybox pops open (which is working fine) and then beforeClose of the fancybox I want to make the iframe visible again due to a z-index issue with the pdf iframe. My issue is that the beforeClose even doesn't seem to be firing. Here is the code I placed below the images and iframe.

<script src="http://www.elevateweb.co.uk/wp-content/themes/radial/jquery.fancybox.pack.js" type="text/javascript"></script>

   var frame = document.getElementById('Frame');

   jQuery("#zoom_08").bind("click", function (e) {
         e.preventDefault();
         var ez = $('#zoom_08').data('elevateZoom');
           $.fancybox(ez.getGalleryList());
           frame.style.display = 'none';
           return false;
    });


    $.fancybox({
      beforeClose: function () {
       frame.style.display = '';
             }
    });

I'm still new to Jquery so I'm not sure I understand what I'm doing wrong. Thanks in advance for any help.

<iframe id="Frame"  width="680" height="1000" runat="server" />

On Page_Load i do the following to set the iFrame's src

 Frame.Attributes.Add("src", "./Files/" + Request.QueryString["certfile"].ToString());

Upvotes: 1

Views: 4475

Answers (1)

JFK
JFK

Reputation: 41143

Try this

jQuery("#zoom_08").bind("click", function (e) {
    e.preventDefault();
    var ez = $('#zoom_08').data('elevateZoom');
    jQuery.fancybox(ez.getGalleryList(), {
        beforeShow: function () {
            frame.style.display = 'none';
        },
        afterClose: function () {
            frame.style.display = ''; // or .display = "block"; ?
        }
    });
    return false;
});

... and remove :

$.fancybox({
  beforeClose: function () {
   frame.style.display = '';
         }
});

because that beforeClose would be for a fancybox that is opening nothing.

Upvotes: 2

Related Questions