title: Invoking a jQuery function after .each() has completed
body: <p>In jQuery, is it possible to <em>invoke a callback</em> or <em>trigger an event</em> after an invocation of <code>.each()</code> (or any other type of iterative callback) has <strong>completed</strong>.</p>
  
  <p>For example, I would like this "fade and remove" to complete</p>
  
  <pre><code>$(parentSelect).nextAll().fadeOut(200, function() {
      $(this).remove();
  });
  </code></pre>
  
  <p>before doing some calculations and inserting <em>new</em> elements after the <code>$(parentSelect)</code>. My calculations are incorrect if the existing elements are still visible to jQuery and sleeping/delaying some arbitrary amount of time (200 for each element) seems like a brittle solution at best.</p>
  
  <p>I can easily <code>.bind()</code> the necessary logic to an event callback but I'm not sure how to cleanly invoke the <code>.trigger()</code> after the above iteration has <em>completed</em>. Obviously, I can't invoke the trigger inside the iteration as it would fire multiple times.</p>
  
  <p>In the case of <code>$.each()</code>, I've considered adding something to the end of the data argument (that I'd manually look for in the iteration body) but I'd hate to be forced to that so I was hoping there was some other elegant way to control the flow with respect to iterative callbacks.</p>