[Solved] (Cycle) Multiple slideshows in tabs - how to show correct image counts for each?

[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.


The image count code is that from http://jquery.malsup.com/cycle/count.html - I've tried moving it inside the .each() statements without success.  

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
  1. // Cycle

  2. $('.slide-wrapper').each(function(){
  3. // add slide navigation
  4.   $(this).append('<a id="prev-slide">< Prev&nbsp;</a><a id="next-slide">&nbsp;Next ></a><p class="count"></p>');
  5.     $('.slide',this).cycle({
  6.     next: $(this).find('#prev-slide'),
  7.     prev: $(this).find('#next-slide'),
  8.     timeout: 0,
  9.     after: onAfter
  10.     });
  11. });

  12. // Cycle image count
  13. function onAfter(curr,next,opts) {
  14.   var caption = 'Image ' + (opts.currSlide + 1) + ' of ' + opts.slideCount;
  15.   $('.count').html(caption);

HTML
  1. <div id="content">

  2. <div class="tabs-container"><h2>Slideshow 1</h2>
  3. <div class="slide-wrapper">
  4. <div class="slide">

  5. <img src="image_01.jpg" alt="" />
  6. <img src="image_02.jpg" alt="" />
  7. <img src="image_03.jpg" alt="" />

  8. </div>  
  9. </div>
  10. </div>

  11. <div class="tabs-container"><h2>Slideshow 2</h2>
  12. <div class="slide-wrapper">
  13. <div class="slide">

  14. <img src="image_04.jpg" alt="" />  
  15. <img src="image_05.jpg" alt="" />
  16. <img src="image_06.jpg" alt="" />
  17. <img src="image_07.jpg" alt="" />

  18. </div>  
  19. </div>
  20. </div>

  21. </div><!-- / #content -->