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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:04:38+00:00 2026-06-04T23:04:38+00:00

Been having fun with this one Trying to use Colorbox to load a gallery

  • 0

Been having fun with this one

Trying to use Colorbox to load a gallery of images where the URL’s are loaded via JSON call without displaying the images on the main page

crawled over the example for flickr at
http://www.jacklmoore.com/demo/flickr.html

having tried a number of routes I’ve got the code semi-working with

var links = $()
    ,link
    ,img
;

$.getJSON('http://URL/json.json', function(data) {

    $.each(data, function(index, photo) {
        link = $('<a/>', {
            href: photo.url
            ,title: photo.name
        });

        img = $('<img/>').attr({
            src: photo.url
            ,alt: photo.name
        }).appendTo(link);

        links = links.add(link);
    });

    $('#gallery-holder').html(links);
});

$.colorbox({
    rel: 'gallery'
    ,inline: true
    ,href: '#gallery-holder'
});

/*
$.colorbox({
    html:links
    ,rel: 'gallery'
    ,inline: true
});
*/

the JSON looks like

[
   {
      "url":"http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-1_large.jpg",
      "name":"1420 Magnolia (1)"
   },
   {
      "url":"http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-10_large.jpg",
      "name":"1420 Magnolia (10)"
   },
   {
      "url":"http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-11_large.jpg",
      "name":"1420 Magnolia (11)"
   }
]

which builds the hidden div

into

<div style="display: none;" id="gallery-holder">
    <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-1_large.jpg" title="1420 Magnolia (1)">
        <img src="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-1_large.jpg" alt="1420 Magnolia (1)">
    </a>
    <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-10_large.jpg" title="1420 Magnolia (10)">
        <img src="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-10_large.jpg" alt="1420 Magnolia (10)">
    </a>
    <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-11_large.jpg" title="1420 Magnolia (11)">
        <img src="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-11_large.jpg" alt="1420 Magnolia (11)">
    </a>
</div>

However when I run the code in console it displays a colorbox that is holding the container div as a hidden element
when I try passing the object as the inline HTML it displays nothing

Curious if anyone has an idea how I can pass the inner HTML of the hidden div to colorbox to be parsed into a gallery?

  • 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-06-04T23:04:40+00:00Added an answer on June 4, 2026 at 11:04 pm

    You don’t want the links within a hidden div. You want the links shown and then colorbox will display the href value (the image).

    If you look closer at the example, you will see that what is happening is the links have a thumbnail added to them, then those links are added to the array. The array is then colorbox’d. Colorbox intercepts the link clicks and rather than loading the image (in the href) the image is shown in the colorbox.

    There are a couple ways you could go about this, but links to images is the easiest. To achieve what you want, the code should look something like this:

    var links = $(), link;
    
    $.getJSON('http://URL/json.json', function(data) {
    
        $.each(data, function(index, photo) {
            link = $('<a/>', {
                href: photo.url,
                title: photo.name,
                text: photo.name
            });
    
            links = links.add(link);
        });
    });
    
    links.colorbox({rel:'gallery', speed:0});
    
    $('#gallery-holder a').append(links);
    

    The HTML should look like this:

    ​<div id="gallery-holder"></div>​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    And should turn out like this:

    <div id="gallery-holder">
        <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-1_large.jpg" title="1420 Magnolia (1)" class="cboxElement">1420 Magnolia (1)</a>
        <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-10_large.jpg" title="1420 Magnolia (10)" class="cboxElement">1420 Magnolia (10)</a>
        <a href="http://s3.amazonaws.com/ACCOUNT/media/photos/1420-magnolia-11_large.jpg" title="1420 Magnolia (11)" class="cboxElement">1420 Magnolia (11)</a>
    </div>
    

    If you have thumbnails you could use those instead of the text.

    Just to show you how it would work, I created a jsfiddle. The image paths you included are fake (I am sure you know) so I just used random images, but if you replace the fiddle with real image paths you can see it in action.

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

Sidebar

Related Questions

Been having lot's of trouble with this one. Let's say I had the following
I am somewhat new to jQuery but have been having fun trying learn about
Been having real trouble with this one and wondered if someone may have found
So, I've been having fun with this web site that creates random themes for
I been having trouble trying to figure this out. When I think I have
I've been having to do some basic feed processing. So, get a file via
We have been having some debate this week at my company as to how
I've been having problems with this code I had spent the last 3 hours
Hello I have been having trouble with this for a while now. I have
I've been having problems running eclipse. This is the exception that was thrown after

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.