0

サイトにブートストラップを適用し始めました。ブートストラップ カルーセルで動作するように、この次のスクリプトを変更する必要があります

        $(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]);
    });     

    }); 
4

1 に答える 1