[Solved] (Cycle) Multiple slideshows in tabs - how to show correct image counts for each?
I have Cycle slideshows within each of a variable number of tabs, with Prev/Next buttons and an image count indicator.
Everything is working apart from the image count, which has these problems:
Total count is initially that of the slideshow in the last tab on the page. When I move to another image the total shows the correct number, but...
The current image number does not change between tabs. If I advance to image 3 and move to another tab, then it also shows image 3 as current until advanced, whereupon the correct image and total are displayed.
If a pager is added, all tabs show the correct number of images, but how to bring this about for the image count indicator?
JS
- // Cycle
- $('.slide-wrapper').each(function(){
- // add slide navigation
- $(this).append('<a id="prev-slide">< Prev </a><a id="next-slide"> Next ></a><p class="count"></p>');
- $('.slide',this).cycle({
- next: $(this).find('#prev-slide'),
- prev: $(this).find('#next-slide'),
- timeout: 0,
- after: onAfter
- });
- });
- // Cycle image count
- function onAfter(curr,next,opts) {
- var caption = 'Image ' + (opts.currSlide + 1) + ' of ' + opts.slideCount;
- $('.count').html(caption);
- }
HTML
- <div id="content">
- <div class="tabs-container"><h2>Slideshow 1</h2>
- <div class="slide-wrapper">
- <div class="slide">
- <img src="image_01.jpg" alt="" />
- <img src="image_02.jpg" alt="" />
- <img src="image_03.jpg" alt="" />
- </div>
- </div>
- </div>
- <div class="tabs-container"><h2>Slideshow 2</h2>
- <div class="slide-wrapper">
- <div class="slide">
- <img src="image_04.jpg" alt="" />
- <img src="image_05.jpg" alt="" />
- <img src="image_06.jpg" alt="" />
- <img src="image_07.jpg" alt="" />
- </div>
- </div>
- </div>
- </div><!-- / #content -->