Calling lightbox - using inline data to show - jQuery FancyBox


On this site: - I am using this lightbox plugin:

At the bottom of that layout, there are three buttons. They open inline HTML in a lightbox. My code to call it is below in the code box.

The problem is, is that I have them all showing on click, you can see them display and a scrollbar is added on click.

Any suggestions I can do to make it more dynamic so it only loads the one being clicked?

At the end of the day, I would like to be able to show it without the others loading.

thank you!


I have also tried calling external HTML pages, but it sits there with the loading animation.

$(".load-content").fancybox({onStart:function(){$(".hide-data").show();},onCleanup:function(){$(".hide-data").hide()},'overlayOpacity': '.6','overlayColor':'#000000','titleShow': false});

Open in new window

Who is Participating?
remorinaConnect With a Mentor Commented:
the problem lies in the method you're calling the fancy box.

You're using a single call that shows all the .hide-data class then hides them, which affects all your elements because they all have the .hide-data css class

Alternatively try give each link an ID and write the fancybox for that ID

<li class="business-owner_off"><a id="BusinessOwner" href="#business-owner" class="load-content" onclick="javascript:pageTracker._trackPageview('/who-are-you/business-owner');"></a></li>

		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'

Open in new window

catonthecouchproductionsAuthor Commented:
I thought of that, but I didnt want to have 7 extra lines, wasnt sure if there was a more dynamic way. But if that seems to be the way, I can go ahead with that.

Then each will open div X


Yes, each will open the div in the href.
It can still be implemented as dynamic but that would require detecting the related element and going through a loop of all the others with the same class setting their visibility to hidden.
I haven't done it that way before but the concept should be valid, it's just going to take much time and testing to make it work, and probably you'll still end with several lines of script which wouldn't be worth the effort unless you had a lot more than just 7
catonthecouchproductionsAuthor Commented:
Exactly, I just went ahead and made each line have its own ID/call.

Thank you!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.