The way it's currently written causes the hide to fire over and over if msg.d starts returning 'false' from 'true' until enough time has passed for the animation to stop.
Is there an isHiding or something?
Thanks in advance!
if(msg.d == "true") {
if(!$("#addContactEmailError").is(":visible")) {
$("#addContactEmailError").show('bounce');
}
$("#addContactSubmitButton").attr("disabled", true);
}
else {
if($("#addContactEmailError").is(":visible")) {
$("#addContactEmailError").hide('slide', { direction: "up" });
}
$("#addContactSubmitButton").attr("disabled", false);
}
Edit 1
This is all in a keyup handler.
Edit 2
Using animated only fires the animation when it's completed. If msg.d changes, but the now incorrect animation isn't finished, the correct animation won't fire.
Lame Solution
I used a global boolean to keep track of the state. I hate doing that. Putting up a bounty for a better solution when I can. Thanks to all!
Canceled Bounty
Sorry guys, didn't realize I had to buy with my own rep. :(
$(elem).is(':animated')
? – Reena