I have that kind of code to append an li element to a given ul with a fancy effect, then I call a function whose behavior depends on the # of children of that ul :
$(li).hide().appendTo("#ul-authors").show("blind");
toggleIfNeeded();
...
function toggleIfNeeded() {
if ($("#ul-authors > li").length === 1) {
doSomething();
} else {
doSomethingElse();
}
}
The problem is, when toggleIfNeeded is called, the new li does not seem to exist yet, since the effect is not totally performed. If I remove the effect, it works correctly.
How can I do that ? I guess I need some sort of a timer, but that would be asynchronous (I don't want to block the app for a fancy effect) or, even better, a way to tell "call that function when the effect is performed".
I don't have the possibility to change 1 with 0 in the above since the code can be called in other contexts where no effect is involved.
.show("blind", toggleIfNeeded)