tags:

views:

44

answers:

1

I recently got some help on here from SLaks (thank you) on the behavior of my custom gallery. I'm now trying to fix the way the thumbnails function. I've been toying with it for about an hour but I can't get it to work. Live version of the code: http://www.studioimbrue.com . Currently the code is as follows:

$('.thumbscontainer ul li a').click(function() {
var li_index = $(this).parents('ul').children('li').index($(this).parent("li"));

    $(this).parents('.thumbscontainer').parent().find('.captions ul li').fadeOut();
 $(this).parents('.thumbscontainer').parent().find('.captions ul li:eq('+li_index+')').fadeIn();
});

$('.container .captions li').click(function() {
    var nextLi = $(this).fadeOut().next().fadeIn();

    if (nextLi.length === 0)  //If we're the last one,
        nextLi = $(this).siblings(':first-child').fadeIn();
});

The only problem is that when the gallery image is clicked, it goes to the next image in the series, yet the thumbnails do not change to the next one in the list. You can take a look at my previous question to see our discussion. Thanks

A: 

You're welcome.

Like this:

var nextThumb = nextLi
    .closest('.container')
    .find('.thumbscontainer li:eq(' + nextLi.index() + ')');

nextThumb
        .addClass(clickedClass).fadeTo(1, activeOpacity)
    .siblings()
        .fadeTo(1, inactiveOpacity).removeClass(clickedClass);

This must be in the same block as

var activeOpacity   = 1.0,
    inactiveOpacity = 0.6,
    fadeTime = 100,
    clickedClass = "selected",
SLaks
Hah, thank you again. It didn't seem to work. I'm looking now but I can't figure out why...http://www.studioimbrue.com/index2.php
steve
You need to put my code into the `click` handler after `nextLi`, and put the entire click handler (from the other answer) in the block with the `var` statement.
SLaks
Ah okay. You're awesome at this... I have lots to learn haha.The only problem now is (check the index2.php) at first it won't scroll through when the gallery is clicked, but once you activate a different thumbnail, it begins working properly. The code we have now is beyond my reach so I'm a bit lost...
steve
Update to the latest version of jCarousel, then add `nextThumb.closest('.thumbscontainer').jcarousel('next');`
SLaks
Excellent.The current two problems I'm having:when the page loads, when you click on the main gallery image, nothing happens. You have to click on a thumbnail to get it to change, then the gallery image click functionality begins working. Weird.The other problem is obvious: when it is clicked, the whole gallery thumbnails scroll every time you click
steve
I reposted it here with the new questions: http://stackoverflow.com/questions/2710772/jquery-custom-gallery-and-jcarousel-problemThanks for all your help!
steve