2012-01-06 11 views
0

私はこのページャーを稼働させました:http://jquery.malsup.com/cycle/pager6.html 私は1ページに複数のスライドショーがあり、ページャーにIDを使用したくない場合はどうなりますか? しかしクラスXの最も近い要素をページャーとして使用してください。jQueryサイクル・ページャー

これはできますか?

これは私の現在のコードです:

$(document).ready(function() 
{ 
    $('.photoGallerySlideshowAlbum').cycle(
    { 
     fx: 'fade', 
     pager: '#photoGallerySlideshowPager', 
     activePagerClass: 'selected', 
     pagerAnchorBuilder: function(idx, slide) 
     { 
      return '#photoGallerySlideshowPager li:eq(' + idx + ') a'; 
     }, 
     after: function(currentImage, nextImage, options) 
     { 
      var captions = $(this).parent().parent().find('.photoGallerySlideshowCaptions').children().hide(); 
      var caption = $(captions[options.currSlide]); 
      caption.show(); 
     } 
    }); 
}); 

私はこのように今それをやった:

$(document).ready(function() 
{ 
    $('.photoGallerySlideshowAlbum').each(function(index, value) 
    { 
     var elPager = $(this).parent().find('.photoGallerySlideshowPager'); 

     $($(this)).cycle(
     { 
      fx: 'fade', 
      pager: elPager, 
      activePagerClass: 'selected', 
      pagerAnchorBuilder: function(idx, slide) 
      { 
       return 'li:eq(' + idx + ') a'; 
      }, 
      after: function(currentImage, nextImage, options) 
      { 
       var captions = $(this).parent().parent().find('.photoGallerySlideshowCaptions').children().hide(); 
       var caption = $(captions[options.currSlide]); 
       caption.show(); 
      } 
     }); 
    }); 
}); 

しかし、私はpagerAnchorBuilderを変更する方法がわかりません。 私のHTMLはこのように見えます(変更できません)。

jQueryのサイクルで
<div class="photoGallerySlideshowPager"> 
        <ul> 
<li><a href="#">a</a></li> 
<li><a href="#">b</a></li> 
<li><a href="#">c</a></li> 
        </ul> 
       </div> 
+0

私は私はあなたの質問を得るのか分からない。複数のスライドショーが必要なのでしょうか?ここに別のものを作ることができませんでしたか?何か不足していますか?ページャのIDを使いたくないということはどういう意味ですか? – rgin

+0

jQueryサイクルのページャプロパティは、デモの要素のIDを受け取り、初期化されている現在のスライダを基準にして何かを渡したいとします。 – Vigrond

答えて

0

それは述べREF:

pager:   null, // element, jQuery object, or jQuery selector string for the element to use as pager container 

http://jquery.malsup.com/cycle/options.html

だから、あなたがそうのように、このプロパティにjQueryオブジェクトを渡すことができる必要があります:

pager: $(this).closest('.nav')