Having trouble with Cycle plugin and activeSlide class

Having trouble with Cycle plugin and activeSlide class

I'm attempting to use the activeSlide class in the Cycle plugin, but I can't seem to get it to work properly using existing markup for the pager.

This is the code that I started with, and it works just fine (thanks to pritaeas.net):

  1. <style type="text/css"> 
  2. #nav { margin: 5px; }
  3. #nav a { margin: 5px; padding: 3px 5px; border: 1px solid #ccc; background: #fff; text-decoration: none }
  4. #nav a.activeSlide { background: #f00; }
  5. #nav a:focus { outline: none; }
  6. </style> 
  7. <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> 
  8. <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script> 
  9. <script type="text/javascript" src="js/cufon-yui.js"></script>
  10. <script type="text/javascript" src="font/MTRCT_400.font.js"></script>

  11. <script type="text/javascript">
  12. Cufon.replace('#nav a', { fontFamily: 'MTRCT' ,hover: true});
  13. </script>

  14. <script type="text/javascript"> 
  15. $(function() {
  16. $('#slideshow').cycle({
  17. speed:       200,
  18. timeout:     0,
  19. pager:      '#nav',
  20. prev: '#prev',
  21. next: '#next',
  22. });
  23. });
  24. </script> 
  25. </head> 
  26. <body> 
  27. <div id="main"> 
  28. <div class="testWrapper">
  29. <div id="nav"></div>
  30. </div> 
  31. <div id="slideshow" class="pics"> 
  32. <img src="images/art_001.jpg" /> 
  33. <img src="images/art_002.jpg" /> 
  34. <img src="images/art_003.jpg" /> 
  35. </div> 
  36. </div>

But, the changes that I've made below that accommodate the page I'm designing break the activeSlide, even though the pager and previous/next function perfectly:

  1. <style type="text/css"> 
  2. #nav { margin: 5px; }
  3. #nav a { margin: 5px; padding: 3px 5px; border: 1px solid #ccc; background: #fff; text-decoration: none }
  4. #nav a.activeSlide { background: #f00; }
  5. #nav a:focus { outline: none; }
  6. </style> 
  7. <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> 
  8. <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script> 
  9. <script type="text/javascript" src="js/cufon-yui.js"></script>
  10. <script type="text/javascript" src="font/MTRCT_400.font.js"></script>

  11. <script type="text/javascript">
  12. Cufon.replace('#nav a', { fontFamily: 'MTRCT' ,hover: true});
  13. </script>

  14. <script type="text/javascript"> 
  15. $(function() {
  16. $('#slideshow').cycle({
  17. speed:       200,
  18. timeout:     0,
  19. pager:      '#nav',
  20. prev: '#prev',
  21. next: '#next',
  22. pagerAnchorBuilder: function(idx, slide) { 
  23. return '#nav li:eq(' + (idx+1) + ') a';
  24. }
  25. });
  26. });
  27. </script> 
  28. </head> 
  29. <body> 
  30. <div id="main"> 
  31. <div class="testWrapper">
  32. <div id="nav">
  33. <ul>
  34. <li><a href="" id="prev">Prev</a></li>
  35. <li><a href="">1</a></li>
  36. <li><a href="">2</a></li>
  37. <li><a href="">3</a></li>
  38. <li><a href="" id="next">Next</a></li>
  39. </ul>
  40. </div>
  41. </div> 
  42. <div id="slideshow" class="pics"> 
  43. <img src="images/art_001.jpg" /> 
  44. <img src="images/art_002.jpg" /> 
  45. <img src="images/art_003.jpg" /> 
  46. </div> 
  47. </div>

I would really appreciate any help. Thanks!