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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:50:51+00:00 2026-05-24T15:50:51+00:00

Firstly I am very new to all forms of javascript, particularly anything remotely AJAX.

  • 0

Firstly I am very new to all forms of javascript, particularly anything remotely AJAX. That said, over the course of the last day I have managed to code a script that dynamically refreshes a single div and replaces it with the contents of a div on another page.

The problem however is that several of my other scripts do not work in the ajax refreshed content. The most important of which being “colorbox”.

I have spent several hours this evening researching this and am seeing lot’s of stuff regarding .load, .live… updating the DOM on refresh etc…etc… But to be quite honest most of it is going over my head currently and I wouldn’t know where to begin in terms of integrating it with the code I currently have.

My Ajax refresh code is as follows (My apologies if I haven’t used best practice, it was my first attempt):-

$(function()  {

$(".artist li.artist").removeClass("artist").addClass("current_page_item");
$("#rightcolumnwrapper").append("<img src='http://www.mywebsite.com/wp-content/images/ajax-loader.gif' id='ajax-loader' style='position:absolute;top:400px;left:190px;right:0px;margin-left:auto;margin-right:auto;width:100px;' />");

var $rightcolumn = $("#rightcolumn"),       
    siteURL = "http://" + top.location.host.toString(),     
    hash = window.location.hash,
    $ajaxSpinner = $("#ajax-loader"),
    $el, $allLinks = $("a");
            $ajaxSpinner.hide();


$('a:urlInternal').live('click', function(e) { 
    $el = $(this);
    if ((!$el.hasClass("comment-reply-link")) && ($el.attr("id") != 'cancel-comment-reply-link')) {         
        var path = $(this).attr('href').replace(siteURL, '');
        $.address.value(path);
        $(".current_page_item").removeClass("current_page_item");
        $allLinks.removeClass("current_link");
        $el.addClass("current_link").parent().addClass("current_page_item");
        return false;
    }

    e.preventDefault();

});  

$.address.change(function(event) {      
    $ajaxSpinner.fadeIn();
    $rightcolumn.animate({ opacity: "0.1" })
    .load(siteURL + event.value + ' #rightcolumn', function() {
        $ajaxSpinner.fadeOut();
        $rightcolumn.animate({ opacity: "1" });
    });
});});

I was hoping someone might be kind enough to show me the sort of modifications I would need to make to the above code in order to have the colorbox load when the contents of #rightcolumn have been refreshed.

There is also a second part to this question. My links to the pictures themselves are now also being effected by the hashtag due to the above code which will in turn prevent the images themselves from loading correctly in the colorbox I should imagine. How can I prevent these images from being effected and just have them keep the standard URL. I only want the above code to effect my internal navigation links if at all possible.

Many thanks guys. I look forward to your replies.

  • 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-24T15:50:52+00:00Added an answer on May 24, 2026 at 3:50 pm

    That’s a lot of code to review so I’ll focus first on the conceptual side of things. Maybe that you will give you some clues…

    It sounds like when you load content via Ajax the DOM is changed. No worries, that’s kind of what we expect. However, scripts loaded before the Ajax calls may have difficulty if they are bound to elements that weren’t there at page load time or are no longer there.

    JQuery’s live function is one solution to that. Instead of binding to a specific element (or collection of elements) at particular point in time, live lets you specify a binding to an element (or collection) of elements without regard to when they show up in the DOM (if ever).

    ColorBox, however, in its default “vanilla” use abstracts that all away and, I believe, uses classic DOM binding – meaning the elements must be present at bind time. (Since you don’t show your call to ColorBox I can’t see how your using it.)

    You may want to consider re-initalizing ColorBox after each content load by Ajax to be certain the binding happens the way you need it to.

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

Sidebar

Related Questions

Firstly, let me just say that I'm very new to JSR-170 and Jackrabbit/Lucene in
Firstly, I am very new to function pointers and their horrible syntax so play
Firstly, I realise that this is a very similar question to this one: Which
Firstly I'm very new to web development so forgive me if this is a
Firstly I am very new to JAVA, so I apoligise if I am not
Firstly, I was wondering if there was some kind of built in function that
Firstly I know that there are many question and solutions to correct thread marshalling
Firstly, let me start by saying that I haven't ever directly used SQL views.
I should first share all what I know - and that is complete chaos.
Firstly, I should say I'm completely new to Pylons, trying to learn web development

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.