views:

370

answers:

2

Hi there,

I have a click event that checks to see if a form is correct i.e. filled out details.. and then i call a function that does this

$('#message_text').html(text);
$('#message_system').fadeIn("slow");
$('#message_system').animate({ opacity: 1.0 }, 5000)
                    .fadeOut('slow', function() {
                        $(this).hide();
                    });

All works ok, as long as i wait .. if i double click the button twice for example that it stops displaying ...

I presume if it is hidden hide() then fadeIn() will automatically show it?

Anyone got any experience with this ??

What i probably would like to do is on the second click then disgard current effects and redisplay new messaage

THanks

+1  A: 

I'm not sure if this is what you're after, but have you looked at the stop() method. You can skip straight to the end of any current animations by calling $('#message_system').stop(true, true) before beginning again.

Dave Cluderay
A: 
if ( ! $(this).is(':animated') ) {
    // Do the animation...
}
J-P