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 5962951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:10:41+00:00 2026-05-22T19:10:41+00:00

I have built a site for a client and when the user clicks on

  • 0

I have built a site for a client and when the user clicks on a navigation link, the content of the linked page is dynamically loaded and transitioned in with JQuery, instead of loading the new page.

The problem I am having is that because it is not loading a new page, $(document).ready doesn’t fire again and any JS on the individual pages gets broken. For example, if you visit http://www.woodlandexotica.com/species.php the page works correctly, but if you try to navigate to the page from http://www.woodlandexotica.com/index_dev.php, the JS won’t work.

I’m not an expert in JS and I really appreciate any and all help!

  • 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-22T19:10:42+00:00Added an answer on May 22, 2026 at 7:10 pm

    The way you organized this code is wrong

    Keep only binding’s inside document.ready and move the logic outside to a functions..which can be accessed by any page.

    $(document).ready(function() {
    
    
        //////////////////////////////////////////////////
        //////////////////////////////////////////////////
    
        // CONTENT BG SLIDESHOW
    
        //////////////////////////////////////////////////
        var photos = ["images/bg01.jpg", "images/bg02.jpg", "images/bg03.jpg"];
    
        var slideshowSpeed = 8000;
    
        var interval;   
        var activeContainer = 1;    
        var currentImg = 0;
        var navigate = function(direction) {
            currentImg++;
            if(currentImg == photos.length + 1) {
                currentImg = 1;
            }
    
            // Check which container we need to use
            var currentContainer = activeContainer;
            if(activeContainer == 1) {
                activeContainer = 2;
            } else {
                activeContainer = 1;
            }
    
            showImage(photos[currentImg - 1], currentContainer, activeContainer);       
        };
    
        var currentZindex = 1;
        var showImage = function(photoObject, currentContainer, activeContainer) {
            // Make sure the new container is always on the background
            currentZindex--;
    
            // Set the background image of the new active container
            $("#bgimg" + activeContainer).css({
                "background-image" : "url(" + photoObject + ")",
                "display" : "block",
                "z-index" : currentZindex
            });
    
            // Fade out the current container
            // and display the header text when animation is complete
            $("#bgimg" + currentContainer).fadeOut(function() {
                setTimeout(function() {
                    animating = false;
                }, 500);
            });
            $("#bgimg" + currentContainer).css({
                "z-index" : "1"
            });
            currentZindex = 1;
        };
    
        function photoLoaded() {
            if(!--numPhotosLeft) {
                navigate("next");
    
                interval = setInterval(function() {
                    navigate("next");
                }, slideshowSpeed);
    
                $('#bg_load').fadeOut('fast');
                $('#page_bg').animate({opacity: 1, marginLeft: '-=860'}, 500);
            }
        }
    
        var photos = ["images/bg01.jpg", "images/bg02.jpg", "images/bg03.jpg"];
        var numPhotosLeft = photos.length;
    
        for(var i = 0; i < photos.length; ++i) {
            var img = new Image();
            img.onload = photoLoaded;
            img.src = photos[i];
        }
        //////////////////////////////////////////////////
        //////////////////////////////////////////////////
    
    
    
    
        //////////////////////////////////////////////////
        //////////////////////////////////////////////////
    
        // PAGE TRANSITION
    
        //////////////////////////////////////////////////
    
    
        // ADJUST FOR DEEPLINKING
        var hash = window.location.hash.substr(1);
        var href = $('a.link').each(function(){
            var href = $(this).attr('href');
            if(hash==href.substr(0,href.length-4)){
                var toLoad = hash+'.php #page_bg';
                $('#page_bg').load(toLoad)
            }                                           
        });
    
        $('a.link').click(function() {
    
            var toLoad = $(this).attr('href')+' #page_bg';
            $('#page_bg').animate({opacity: 0.25, marginLeft: '-=875'}, 500, loadContent);
    
            window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4); //MODIFY FOR DEEP LINKING
    
            function loadContent() {
                $('#page_wrap').prepend('<span id="load">LOADING...</span>');
                $('#load').fadeIn('fast');
    
                $('#page_bg').css('marginLeft', 860);
                $('#page_bg').css('backgroundImage', 'none');
                $('#page_bg').load(toLoad,'',hideLoader);
            }
            function hideLoader() {
                $('#load').fadeOut('fast', showNewContent);
            }
            function showNewContent() {         
                $('#page_bg').animate({opacity: 1, marginLeft: '-=860'}, 500);
            }
    
            return false;
        });
    
        //set initial position and opacity
        $('#page_bg').css('marginLeft', 860);
        $('#page_bg').css('opacity', 0.25);
        $('#page_wrap').prepend('<span id="bg_load">LOADING...</span>');
        $('#bg_load').fadeIn('fast');
    
        //////////////////////////////////////////////////
        //////////////////////////////////////////////////
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site built in ASP.NET MVC and uses heavy jQuery client interaction
I have built a Twitter client that's only one page: index.html. When being used,
We have a hosted site that has a CMS we built running on a
I have built a web page which contains a Crystal Report built using the
We have a client whose site is hosted on a server (I don't want
We've built a social networking site for a client. It did very well and
We have a site hosted in IIS6 that we built using the .NET 1.1
I'm an experienced SVN user getting used to TFS at a new client site.
I have a site built on codeigniter but I have come accross a small
Good afternoon people's I have built a jquery plugin that I use on my

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.