0

私は JS の専門家ではありませんが、Royalslider がある場合はそれを表示するようにこれを変更しようとしています... ない場合は静止画像とタイトルと説明を表示します。なぜこれが機能しないのかについてのアイデアはありますか? 私の頭は現在ぐるぐる回っています... //royal Slider fix の下のコードに追加しようとしているセクションの周りにいくらかのスペースを残しており、現在は if ステートメントからのタイトルと説明を表示しているだけです。しかし、マークアップはスライダー div を表示し、コードを出力しています。

どんな助けでも大歓迎です!このコードと私がやろうとしていることをここでプレビューできます... http://bvh.delineamultimedia.com/?page_id=2

;(function($) {

$.fn.SuperBox = function(options) {

    var superbox      = $('<div class="superbox-show"></div>');
    var superboximg   = $('<img src="" class="superbox-current-img">');
    var superboxclose = $('<div class="superbox-close"></div>');

    superbox.append(superboximg).append(superboxclose);

    return this.each(function() {

        $('.superbox').on('click', '.superbox-list', function() {

            //allows for superbox to work inside of quicksand
            $('ul.filterable-grid').css({overflow: 'visible'});

            var currentimg = $(this).find('.superbox-img');
            superbox.find('.title').remove(); 
            superbox.find('.description').remove(); 

            var imgData = currentimg.data();
            superboximg.attr('src', imgData.img);
            if (imgData.title) { superbox.append('<h3 class="title">'+imgData.title+'</h3>'); }
            if (imgData.description) { superbox.append('<div class="description">' + imgData.description + '</div>'); }









//royal slider fix              
superbox.find('.royalSlider').remove(); // remove the slider from previous events
var imgData = currentimg.data();
var sliderData = currentimg.next('.royalSlider'); // grab the slider html that we want to insert

superboximg.attr('src', imgData.img); 

if (sliderData) { // show the slider if there is one
    superbox.clone().append(sliderData); // clone the element so we don't loose it for the next time the user clicks
} else { // if there is no slider proceed as before
    if (imgData.img) {
        superbox.append(imgData.img);
    }
    if (imgData.title) {
        superbox.append('<h3 class="title">' + imgData.title + '</h3>');
    }
    if (imgData.description) {
        superbox.append('<div class="description">' + imgData.description + '</div>');
    }
}












            if($('.superbox-current-img').css('opacity') == 0) {
                $('.superbox-current-img').animate({opacity: 1});
            }

            if ($(this).next().hasClass('superbox-show')) {
                superbox.toggle();
            } else {
                superbox.insertAfter(this).css('display', 'block');
            }

            $('html, body').animate({
                scrollTop:superbox.position().top - currentimg.width()
            }, 'medium');

        });


        $('.superbox').on('hover', '.superbox-list', function(e) {
            $(this).find('.overlay').stop()[(e.type == 'mouseenter') ? 'fadeIn' : 'fadeOut']('slow');
        });


        $('.superbox').on('click', '.superbox-close', function() {
            $('.superbox-current-img').animate({opacity: 100}, 200, function() {
                $('.superbox-show').slideUp();
            });
        });

    });
};

})(jQuery);
4

1 に答える 1

0

これは、問題全体を解決しようとするものではなく、ヒントを提供することのみを目的としています。

これを試して:

var superbox      = $('<div class="superbox-show"/>');
var superboximg   = $('<img src="" class="superbox-current-img"/>');
var superboxclose = $('<div class="superbox-close"/>');

if (sliderData.length > 0)

imgData.img はどこで値を取得していますか?

于 2013-03-28T13:57:11.213 に答える