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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:13:39+00:00 2026-05-28T13:13:39+00:00

This is a ‘hack’ that enables the colorbox jQuery plugin to work with the

  • 0

This is a ‘hack’ that enables the colorbox jQuery plugin to work with the jQuery live and the rel attribute (so you can group images int he lightbox):

 $('a[rel="group1"]').live('click', function(){ 
    $('a[rel="group1"]:not(.cboxElement)').colorbox(); 
    return false; 
  }).colorbox(); 

Now, the problem is that the lightbox only appears the second time you click on it.

So I thought I could automatically trigger the second click (after the events in the first one are finished).

Any suggestions to accomplish this?

EDIT:

I searched on Google about how to use the jQuery live and colorbox and found this.

Then I realized that it doesn’t work with groups of images.

Then I found this hack but it requires a second click.

Dynamically generated HTML:

$('#menu-item-27052').append("<a rel='group1' href='images/orion_beer.jpg'>test</a>")
$('#menu-item-27052').append("<a rel='group1' href='images/dish2.jpg'>test 2</a>")
  • 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-28T13:13:39+00:00Added an answer on May 28, 2026 at 1:13 pm

    Well you can call $(this).trigger('click', false), the false passes an argument to the event handler that you can check the existence of so you don’t run an infinite loop:

    $('a[rel="group1"]').live('click', function(event, reTrigger){
        $('a[rel="group1"]:not(.cboxElement)').colorbox();
        if (typeof(reTrigger) == 'undefined' || reTrigger == false) {
            $(this).trigger('click', false);
        }
        return false; 
    }).colorbox();
    

    I’m not sure what you’re accomplishing with this but it seems like a strange work-around. Perhaps your code can call the colorbox plugin in a different way.

    Maybe you should run .colorbox() on the elements as they are added to the DOM so when they are clicked it’s already setup and ready to go.

    Update

    $('#menu-item-27052').append("<a rel='group1' href='images/orion_beer.jpg'>test</a>");
    $('#menu-item-27052').append("<a rel='group1' href='images/dish2.jpg'>test 2</a>");
    $('.group1').colorbox();
    

    Just call the .colorbox() function on the elements after they have been added to the DOM. If the Colorbox plugin has a “destroy” method to remove instances, then you should call that first:

    $('#menu-item-27052').append("<a rel='group1' href='images/orion_beer.jpg'>test</a>");
    $('#menu-item-27052').append("<a rel='group1' href='images/dish2.jpg'>test 2</a>");
    $('.group1').colorbox.remove().colorbox();
    

    On a side-note you should concoct a string and append all the DOM elements at once, if you use .append() a bunch it will slow down the execution of the code:

    $('#menu-item-27052').append("<a rel='group1' href='images/orion_beer.jpg'>test</a><a rel='group1' href='images/dish2.jpg'>test 2</a>");
    $('.group1').colorbox.remove().colorbox();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a snippet of the code that doesn't work right. The closing </script>
This is a bit of a long shot, but if anyone can figure it
This is beyond both making sense and my control. That being said here is
This seems 101-level, but I can't find an answer! (instead I find links to
This is my first day coding and using jquery, I figured the best way
This is probably basic stuff, but I can't find the clear answer anywhere.. Lets
Does anyone know how can I replace this 2 symbol below from the string
This is my first time creating a PHP form that will run a MySQL
This question has been asked before but that was three years ago and Microsoft
This is a mailing list script. It works by itself without jquery but I

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.