Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7037211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:31:01+00:00 2026-05-28T01:31:01+00:00

We are using Fancybox to provide a lightbox for our image gallery. We have

  • 0

We are using Fancybox to provide a lightbox for our image gallery.

We have a ul with class ‘images’. Each list item contains an anchor tag and an image inside of it. The anchor tag contains an href of the full sized image.

This code is used to set up the lightbox.

<script type="text/javascript">
//<![CDATA[
    $(document).ready(function () {
        if (!themeJSEnabled) {
            $(".images a").fancybox({
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'titlePosition': 'inside',
                'autoScale': true,
                'centerOnScroll': true,
                'overlayOpacity': .95,
                'titleFromAlt': true,
                'scrolling': 'no'
            });
        }
    });
//]]>
</script>

This works fine for most of our private labels, but one particular style doesn’t work.

The style that doesn’t work uses javascript to rip apart part of the DOM and reconstruct it (as follows)

 $("#subcontent2").before("<div class='combinedContentWrapper'></div>");
 $("div.combinedContentWrapper").append("<div class='combinedContent'></div>");
 $("div.combinedContent").append("<div class='sc1'></div>");
 $("div.combinedContent").append("<div class='mc'></div>");
 $("div.mc").append($(".maincontent").html());
 $("div.sc1").append($(".subcontent1").html());
 $("div.maincontent").remove();
 $("div.subcontent1").remove();
 $("div.mc").addClass("maincontent");
 $("div.sc1").addClass("subcontent1");

In themes of this style themeJSEnabled (from the first code block) is true, so AFTER the DOM is reconstructed with the above code, I use the following code to register the Fancybox:

 $(".images a").fancybox({
      'transitionIn': 'elastic',
      'transitionOut': 'elastic',
      'titlePosition': 'inside',
      'autoScale': true,
      'centerOnScroll': true,
      'overlayOpacity': .95,
      'titleFromAlt': true,
      'scrolling': 'no'
  });

As I understand it, this should work, as I didn’t register anything before the DOM was reconstructed, and the fancybox should be registering on the new elements.

However, when I first click any image in the list, it throws a javascript error – ‘t is undefined’. This error is listed as being on line 17, within a completely unrelated method. The error still occurs even if that method is surrounded by a try/catch block. The error does NOT occur on subsequent clicks on images, which product no result.

What can I do to get the Fancybox to work in this situation?

You can see an example live on our test server at this link. Click on ‘Images’, then click an image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:31:02+00:00Added an answer on May 28, 2026 at 1:31 am

    Ok, we eventually found the cause.

    When we modify the DOM, it seems to lose the references to the fancybox javascript.

    This was fixed by moving the fancybox references to the head as follows:

    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptInclude(this.Page, GetType(), "fancybox1", "scripts/FancyBox/jquery.fancybox-1.3.4.pack.js");
        ScriptManager.RegisterClientScriptInclude(this.Page, GetType(), "fancybox2", "scripts/FancyBox/jquery.mousewheel-3.0.4.pack.js");
        Page.Header.Controls.Add(new LiteralControl("<link rel=\"stylesheet\" type=\"text/css\" href=\"scripts/FancyBox/jquery.fancybox-1.3.4.css\" />"));
    }
    

    Once we did this, it started working for us.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a standard image gallery using FancyBox. The page shows a list of
I'm using fancybox to show some images in a gallery. I have a main
I'm using fancyBox to create a gallery with the following code: <a class=fancybox rel=group1
I'm using Fancybox to load some content with AJAX. Content: <div class="container"> <h2>An image</h2>
I'm using Fancybox as a lightbox. I have videos set up in external html
I am using fancybox to display some images. Currently when users hover the image,
I am using fancybox on a series of gallery images. The user has the
I am building a web app image gallery using FancyBox. Right now I am
I'm using the Fancybox plugin for an image gallery, and I want to display
I am using FancyBox to generate a popup image. FancyBox (In case you are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.