Fancybox not working on dynamically added external links

43 views
Skip to first unread message

Lalas Muathasim

unread,
Nov 20, 2017, 1:45:25 AM11/20/17
to FancyBox

I have a list of items as follows

<ul>
 <li><a href="http://toExtUrl/img.jpg" class="should-popout">
  <img src="http://mywebsite.com/icon.png"></a>
 </li>
</ul>

toExtUrl/img.jpg is added dynamically and it may sometimes shows pdf or HTML content instead of images(This is always external link). I'm trying to give the fancybox popout effect for whatever comes with href attribute of '.should-popout'.

But while clicking it just redirection to external url happens. My fancybox option is as follows

$(window).on('load', function(){
 $('a.should-popout').fancybox({
    'autoDimensions' : true,
    'autoScale' : true
    'hideOnContentClick': true,
    'showCloseButton' : true
 });
});

What may be the error in the setup.

Reply all
Reply to author
Forward
0 new messages