user2519032
user2519032

Reputation: 829

Link inside the Fancybox popup

I'm triggering Fancybox popup automatically when the page is loaded.

Inside that popup there's a HTML content with link to other page.

That link doesn't work when it's loaded with Fancybox.

Here's my code:

<div class="popup">
  <div class="container">
    <h4>Description text...</h4>
    <a class="btn btn-green" href="/the_url_of_the_page">View more</a> //this link is not working
  </div>
</div>

  <script>
    $(document).ready(function() {
      $('.popup').fancybox({
        transitionEffect : "zoom-in-out",
      }).trigger('click');
    });
  </script>

How can I set that link to work?

I'm using Fancybox v3.1.28

Upvotes: 0

Views: 120

Answers (1)

Janis
Janis

Reputation: 8769

First, links, buttons, etc are working perfectly fine in fancybox.

The problem in your example is caused by the fact that you have used .popup selector to initialize fancybox, but that matches element containing your link. So, your code can be translated to 'start fancybox when user clicks on element having class ".popup"'. But, your link is inside element with class name ".popup", therefore it starts fancybox.

Finally, your code does not make any sense. If you wish to immediately start fancybox, then use $.fancybox.open() method, see https://fancyapps.com/fancybox/3/docs/#api for samples

Upvotes: 1

Related Questions