2013-07-22 44 views
0

我開始在我的網站上應用bootstrap。 我需要改變這個下面的腳本上引導傳送帶Bootstrap旋轉木馬:將jquery幻燈片更改爲引導caroulsel並綁定幻燈片功能

 $(function(){ 
      // Set starting slide to 1 
      var startSlide = 1; 
      // Get slide number if it exists 
      if (window.location.hash) { 
       alert('hash'+window.location.hash); 
       startSlide = window.location.hash.replace('#',''); 
       alert('startslide'+startSlide); 
      } 
      // Initialize Slides 
      $('#slides2').slides({ 
       preload: true, 
       preloadImage: 'img/loading.gif', 
       generatePagination: true, 
       play: 0, 
       pause: 2500, 
       hoverPause: true, 
       currentClass: 'current', 
       // Get the starting slide 
       start: {$startNumb}, 
       animationComplete: function(current){ 
        // Set the slide number as a hash 
        window.location.hash = '#' + current; 
        alert('windows hash'+window.location.hash); 
        alert('current'+current); 
        $('#activeSlideIndex').val(current); 
        $('#popLightbox div.rating a').attr('rel', imageIdArray[current-1] +';media'); 
        $('#popLightbox a.voteNegative').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/unlike.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][0]); 
        $('#popLightbox a.votePlus').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/approve.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][1]); 
       } 
      }); 

我已經試過這樣的工作,但它不能正常工作。 我不知道哪裏是current變量中獲得的價值,以及如何window.location.hash工作

$(function(){ 
     // Set starting slide to 1 
     var startSlide = 1; 
     // Get slide number if it exists 
     if (window.location.hash) { 
      startSlide = window.location.hash.replace('#',''); 
     } 
     $('#myCarousel').bind('slide',function(current){ 
      window.location.hash = '#' + current; 
      $('#activeSlideIndex').val(current); 
      $('#popLightbox div.rating a').attr('rel', imageIdArray[current-1] +';media'); 
      $('#popLightbox a.voteNegative').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/unlike.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][0]); 
      $('#popLightbox a.votePlus').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/approve.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][1]); 
    });  

    }); 

回答

0

發現solution.This一方獲得該轉盤的當前索引

$('#myCarousel').bind('slid',function(e){ 
      var current = $(".active", e.target).index()+1; 
       $('#activeSlideIndex').val(current); 
       $('#popLightbox div.rating a').attr('rel', imageIdArray[current-1] +';media'); 
       $('#popLightbox a.voteNegative').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/unlike.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][0]); 
       $('#popLightbox a.votePlus').html('<img src="{$liveSite}/templates/{$theme}/desktop_images/images/approve.png" align="absmiddle"><b class="sprite">&nbsp;</b> ' + voteCountArray[current-1][1]); 
     }); 
相關問題