tags:

views:

25

answers:

1

I have the following code which is used to slidein/out a div (shopping basket) on a page. However, the code will only fire once (open once, close once). Does the toggle need to be reset in some way?

$(document).ready(function(){

    var miniBasketHeight = -$('#minibasket div.outer').height();

    $('#minibasket a.opener').toggle(
        function(e) {
            console.log("open");
            e.preventDefault();
            $(this).parent().find('div.outer').animate({top: 0, opacity: 1 }, 700 );
        },
        function(e) {
            console.log(miniBasketHeight);
            e.preventDefault();
            $(this).parent().find('div.outer').animate({top: miniBasketHeight, opacity: 0 }, 700 );
        }
    );
});
A: 

This has now been resolved using slideToggle()

$(document).ready(function(){
    $('#minibasket a.opener').click(function(e) {
        e.preventDefault();
        $('div.outer').slideToggle('slow', function() {
            //Animation complete
        });
    });
});
Jeepstone