help with lightbox2

Discussion in 'HTML & Website Design' started by wpg56, Nov 2, 2010.

  1. #1
    I am using lightbox2.

    For an example -
    On a single webpage page there are thumbnail images of 2 cats, 2 dogs and 2 pigs. The thumbnails open the large images.
    My code is:

    <a href="cat_1.jpg" rel="lightbox[cat]" > <img src="cat_1_T.jpg" /> </a>

    <a href="cat_2.jpg" rel="lightbox[cat]" > <img src="cat_2_T.jpg" /> </a>

    <a href="dog_1.jpg" rel="lightbox[dog]" ><img src="dog_1_T.jpg" /> </a>

    <a href="dog_2.jpg" rel="lightbox[dog]" ><img src="dog_2_T.jpg" /></a>

    etc.. the pig is coded same.

    I want the 3 separate image groups, cats, dogs, pigs just to show 2 of 2 cats or 2 of 2 dogs or 2 of 2 pigs, depending on which group is selected.
    What I get are 6 of 6 images, cats, dogs, pigs all in one group.
    Is it possible to have 3 different groupings one one page?
     
    wpg56, Nov 2, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Last edited: Nov 3, 2010
    Cash Nebula, Nov 3, 2010 IP
  3. wpg56

    wpg56 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    wpg56, Nov 3, 2010 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ah right, some guy has taken lightbox2 and turned it into a jquery plugin, but he also changed the method by which images are grouped.
    Your code in lightbox.js selects all of the images in the image_Single_Container div, but it seems to ignore the lightbox attribute.
    That needs to be changed but I'm not sure what to. Maybe this will work:
    
    $(function() {
            $('a[@rel*=lightbox]').lightBox();
        });
    
    Code (markup):
     
    Cash Nebula, Nov 3, 2010 IP
  5. wpg56

    wpg56 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your reply but that did not work, it removed the light box function totally.
    If the problem is that I changed it into a jquery plugin, how did I do that?
     
    wpg56, Nov 4, 2010 IP
  6. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What I meant was that someone else has turned lightbox2 into a plugin.

    This code should work.
    
    $(function() {
            $('a[@rel*="lightbox[grates]"]').lightBox();
    	$('a[@rel*="lightbox[screens]"]').lightBox();
    	$('a[@rel*="lightbox[tools]"]').lightBox();
    });
    
    Code (markup):
    Another way is to wrap each section in a container ( <div id='grates'>, <div id='screens'>, <div id='tools'> ) and use this code.
    
    $(function() {
    	$('#grates a').lightBox();
    	$('#screens a').lightBox();
    	$('#tools a').lightBox();
    });
    
    Code (markup):
    You can remove the rel attributes from the links if you use this method.
     
    Last edited: Nov 4, 2010
    Cash Nebula, Nov 4, 2010 IP
  7. wpg56

    wpg56 Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thank you Cash Nebula!! Your solution of using divs worked exactly the way I want. Excellent help... Thanks again...
     
    wpg56, Nov 5, 2010 IP
  8. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You're welcome. I found an excellent list of lightbox clones in the process so it's all good :)
     
    Cash Nebula, Nov 5, 2010 IP