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

  • SEARCH
  • Home
  • 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 3691120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:06:43+00:00 2026-05-19T04:06:43+00:00

I have a site w/ an image gallery (Portfolio) page. There is drop-down navigation

  • 0

I have a site w/ an image gallery (“Portfolio”) page. There is drop-down navigation that allows a user to view a specific image in the portfolio from any page on the site. The links in the navigation use a hash, and that hash is read and converted into a string of an image filename. The image src attribute on the /portfolio/ page is then swapped out with the new image filename.

This works fine if I’m clicking the dropdown link from a page OTHER THAN the /portfolio/ page itself. However if I take the same action from the /portfolio/ page, I get a “too much recursion” error in Firefox. Here’s the code:

Snippet of the nav markup:

<li>Portfolio Category A
  <ul>
      <li><a href="/portfolio/#dining-room-table">Dining Room Table</a></li>
      <li><a href="/portfolio/#bathroom-mirror">Bathroom Mirror</a></li>

  </ul>
</li>

JS that reads the hash, converts it to an image filename, and swaps out the image on the page:

$(document).ready(function()
{
    if(location.pathname.indexOf("/portfolio/") > -1)
        {
            var hash = location.hash;
            var new_image = hash.replace("#", "")+".jpg";
            swapImage(new_image);
        }
});

function swapImage(new_image)
{
    setTimeout(function()
    {
        $("img#current-image").attr("src", "/images/portfolio/work/"+new_image);
    }, 100);
}

I’m using the setTimeout function because I’m fading out the old image before making the swap, then fading it back in. I initially thought this was the function that was causing the recursion error, but when I remove the setTimeout I still have this problem.

Does this have to do with a closure I’m not aware of? I’m pretty green on closures.

JS that listens for the click on the nav:

$("nav.main li.dropdown li ul li").click(function()
{
    $(this).find("a").click();
    $("nav.main").find("ul ul").hide();
    $("nav.main li.hover").removeClass("hover");
});

I haven’t implemented the fade in/out functionality for the dropdown nav yet, but I have implemented it for Next and Previous arrows, which can also be used to swap out images using the same swapImage function. Here’s that code:

$("#scroll-arrows a").click(function()
{

    $("#current-image").animate({ opacity: 0 }, 100);

    var current_image = $("#current-image").attr("src").split("/").pop();
    var new_image;
    var positions = getPositions(current_image);

    if($(this).is(".right"))
    {
        new_image = positions.next_img;
    }
    else
    {
        new_image = positions.prev_img;
    }

    swapImage(new_image);

    $("#current-image").animate({ opacity: 1 }, 100);

    return false;
});

Here’s the error I’m getting in Firefox:

too much recursion
var ret = handleObj.handler.apply( this, arguments );
jquery.js (line 1936)

Thanks for any advice.

  • 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-19T04:06:43+00:00Added an answer on May 19, 2026 at 4:06 am

    I would assume that clicking the link also triggers a click on the UL / LI which you observe and in which you execute (another) click on the anchor, which triggers your observer again, and so on. Every time the /portfolio/ then gets reloaded and the ready() fires and somewhere in there it recurses. Have you tried to look at the callstack in the debugger? Should become pretty obvious between which methods it bounces.

    René

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

Sidebar

Related Questions

I have an existing site that requires a background image on the home page.
I'm creating an image gallery site that you have to log in to access.
I have an image gallery within a Drupal site that uses the 'Image Gallery'
I my working on the site that will have image gallery. Designer idea was
I have a site with an image uploader, and whenever a user tries to
I have a site that uses a large centered background image, which naturally loads
Re-writing a photography portfolio site, and urls have to follow the format: [site].com/portfolio/[category]/[image] to
I used a image gallery engine called prettyPhoto.js in a WordPress site that I
I have a user gallery at the site and it is possible for visitors
I have a simple image gallery that I've paginated, and I want to to

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.