title: Make a jquery function wait till it's previous call has been resolved
body: <p>So, I've searched for this high and low and maybe I'm just having trouble understanding jQuery's deferred function or I'm completely on the wrong track. So any help would be appreciated folks!</p>
  
  <p>I basically have a custom jQuery function <code>messager</code> that displays a message with a <code>fadeOut</code> and <code>fadeIn</code>.</p>
  
  <pre><code>(function ( $ ) {
  
      $.fn.messager = function(message, effect, speed) {
  
          $(this).fadeOut(speed).delay(speed).text(message).fadeIn(speed);
  
          return this;
      };
  
  }( jQuery ));
  </code></pre>
  
  <p>So, I have a div called <code>$elem</code> and when <code>$elem.messager</code> gets called multiple times (with different messages), I would like the messager function to wait till its last call has finished. As in the last <code>FadeIn</code> has finished. Because currently what's happening is that the second call of the function is overwriting the animation effect of the first call of the function. </p>
  
  <p>Any ideas?</p>