Deferreds are a very elegant way to handle calling B once A is completed, or calling B immediately if A is already completed, with this working well no matter how many callbacks are involved.

http://api.jquery.com/jQuery.Deferred/