views:

55

answers:

1

I have a jQuery sliding panel that is not displaying a jQuery carousel within it.

Example: http://www.warface.co.uk/clients/warface.co.uk/

Click Show Dashboard to display the Sliding Panel.

I have the buttons (previous/next) displaying but not the carousel. I have added the carousel below also for example.

I have the CSS for the sliding panel

#panel {
    width: 100%;
    height: 500px;
    color: #999999;
    background: #272727;
    overflow: hidden;
    position: relative;
    z-index: 3;
    display: none;
}

and it seems removing display: none; fixes it but leaves the slider down on page load.

+1  A: 

Cracked it:

You need to hide your panel using height instead of display, like so:

#panel {
    width: 100%;
    height:0px;
    color: #999999;
    background: #272727;
    overflow: hidden;
    position: relative;
    z-index: 3;
    }

Then show it in js by changing height to 500 making your JS this:

$(document).ready(function() {

    // Expand Panel
   $("#open").click(function(e){
       e.preventDefault();
        $("div#panel").animate({height: "500px"},"slow");
    });    

    // Collapse Panel
    $("#close").click(function(e){
        e.preventDefault();
        $("div#panel").animate({height: "0px"},"slow");
    });     

    // Switch buttons from "Log In | Register" to "Close Panel" on click
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });  

     $(".anyClass").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });

});

Note the additon of preventDefault() which prevents the page from jumping to the top, which was neccesary when I was trying it in jsfiddle, but prob won't be needed in live application, none the less it is generally good practice. If you want to see it in action you can do so here: http://jsfiddle.net/LiamBailey/ERQzd/87/ note: because of the limited window size in jsfiddle, you have to scroll down to get to the close panel link leaving you unable to see the panel sliding back up because of preventDefault, to fix this I added a little scroll up $("html,body").animate({scrollTop: target},"fast"); But none of that will be needed for you as the close panel link is visible without scrolling down.

Liam Bailey
I dont understand why this should be changed with js and not in the CSS? This still hides the content of the carousel :(
Rob
You answered your own question when you asked why display:none fixed your problem, but caused it to be displayed all the time. You don't want #panel to be displayed all the time, only when the slideshow is active, as the slideshow is activated with JS you also use JS to show the panel. There is no other way to do it. Put another way Removing display:none from the CSS means it shows the panel all the time, so you **need** to have display:none in your css, thus, to make the panel show you need to remove it somehow as the slideshow is activated, thus you need to use JS.
Liam Bailey
Liam - Thank you very much for your time on this, that worked perfectly thank you!!! :)
Rob