简体   繁体   中英

If/Else Statement showing differently on Click.

http://bvh.delineamultimedia.com/?page_id=2 -> if you click the first image there is a gallery in the dropdown… which is what I want. But, if you close it and re-open it. it goes to a static image.

So there is a function statement in this js I'm working with and can't seem to figure it out what the problem is. http://bvh.delineamultimedia.com/wp-content/themes/bvh/js/portfolio/superbox.js

Here is the function...

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

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

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

// cleanup
superbox.find('.title').remove();
superbox.find('.description').remove();
superbox.find('.royalSlider').appendTo(superboximg);
//superbox.find('.royalSlider').appendTo($(this)); // remove the slider from previous events
//superbox.find('.royalSlider').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

var sliderData = currentimg.siblings('.royalSlider'); // grab the slider html that we want to insert

if (sliderData.length > 0) { // show the slider if there is one
    superbox.append(sliderData); // clone the element so we don't loose it for the next time the user clicks
    superboximg.css('display', 'none');
} else { // if there is no slider proceed as before
    if (imgData.img) {
        superboximg.attr('src', imgData.img);
        superboximg.css('display', 'block');
    }
}







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');

});

If you re-open the page, the browser will just load the url ( http://bvh.delineamultimedia.com/?page_id=2 ) again from scratch. If you want to re-display something, you have to change the url and make sure that JavaScript picks it up. This is commonly done with window.location.hash .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM