2012-03-06 12 views
0

私はjQueryのGallerifficを実装しました。表示される画像のIDを取得しようとしています。そのため、onSlideChangeイベントで取得する必要があります。私はさまざまなjQueryセレクタとGaleriff APIを試してきましたが、私は何か間違っているようです。Gelleriffic:imagedata onSlideChangeイベントを取得する方法

誰でも手伝ってもらえますか?

ザ・jsのコードは次のようである:

var c=jQuery("#gallery-thumbs").galleriffic({ 
      onSlideChange:function(b,c){ 
         //c seems to storage the index of the image which are going to be displayed 
         //at this point there is no li.selected?¿? 
       my_function(image_id); 
         }}); 

function my_function(image_id) { 
    //do something 
} 

そしてHTML:

<div id="gallery-thumbs" style="display: block;"> 
    <ul class="thumbs"> 
    <li class="gallery-thumb selected"> 
     <a href="#1" src="path/full.jpg" class="thumb"> 
     <img src="paths/thumb.jpg" id="this_is_a_id" class="thumb"> 
     </a> 
    </li> 
    <li class="gallery-thumb"> 
     <a href="#2" src="path/full2.jpg" class="thumb"> 
     <img src="paths/thumb2.jpg" id="this_is_other_id" class="thumb"> 
     </a> 
    </li> 
    </ul> 
</div> 
+0

JSFiddleをセットアップしたり、問題のページへのリンクを投稿することはできますか? – Jasper

+0

@ジャスパー、ここで私がしようとしていることの例を見つけることができます:http://www.efxto.com/ejemplo/ejemplo.html。サムネイルimgのIDは、onSlideChangeギャラリアのイベントが発生したときに得ようとしているものです。 – user1253255

答えて

0

onSlideChange関数は二つの引数が渡され、1は、前の画像のインデックスであり、他方があります次のイメージのインデックス

onSlideChange:function(prevIndex, nextIndex){ 

    //start with the `#ims-thumbs` div, 
    //then get it's only child, the UL, 
    //then find all the images in the UL 
    //then select the image we want by index and get it's ID 
    var image_id = $('#ims-thumbs').children().find('img').eq(nextIndex)[0].id; 
    my_function(image_id); 
} 
+0

ありがとうございます!前にも似たような構文を使ってみました。ありがとうございました。 – user1253255

関連する問題