1

I have some articles, each article have a link "Read more", that opens the article inside a fancybox.

Each article, sometimes have pdfs, and I want also to open theese pdfs inside a fancybox.

And I already have this working fine.

What Im having is:

I open my article inside fancybox and then I have inside my article links for pdfs and when I click in thesse links I open pdfs inside fancybox.

But when I close my pdf inside fancybox, I want to open my first fancybox opened, that is fancybox that have that pdf inside.

Im trying to do this using this option inside my function to open pdfs inside fancybox:

afterClose: function() { 
 $(".fancybox").fancybox().trigger("click");
}

But like this, Im not opening my first article opened when I close my pdf fancybox.

I already tried many ways to achieve my goal but its not easy...

Do you know how I can open my first fancybox opened when I close my second fancybox?

You can see my full example here: http://jsfiddle.net/5EV8r/423/

1 Answer 1

1

Changed your code on jsfiddle. You loaded the fancybox twice on the same link. I added a different behavior to the close button to go back to the old fancybox.

afterShow: function() {
    $(".fancybox-close").click(function(e) {
        e.preventDefault();
        $(".fancybox").click();
    });
}

Solution: http://jsfiddle.net/5EV8r/424/

4
  • Thank you for your response. In the fiddle you sent seems to be working. But in my project I am having the same result, when I close my fancybox with pdf, the fancybox that is opened is not my fancybox that contains the artile with pdf opened, is a fancybox with a iframe with a google map that I open when I click in a link that I have in my footer... Do you know why this can be happening??
    – UserX
    Jul 29, 2014 at 23:35
  • 1
    You probably have more than one element with the class fancybox. So you should specify the one you want to open. Give it an id: id="test". And use $("#test").click();. Good luck with that.
    – Vennik
    Jul 29, 2014 at 23:38
  • Thanks for your answer Vennik! But I can have a lot of articles, because Im inserting articles dynamically with php. And each article have a "Read more" link with "fancybox" class, so I can open each article inside fancybox. So I will have always a lot of articles with class="fancybox". Do you know how can I solve this situation?
    – UserX
    Jul 29, 2014 at 23:43
  • Thank you so much. I was for a long time trying to do this. Thank you really :)
    – UserX
    Jul 30, 2014 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.