title: jQuery Transit animation not executing within for loop properly
body: <p>I am using <a href="http://ricostacruz.com/jquery.transit/" rel="nofollow">jQuery Transit</a> to animate a changing  element. </p>
  
  <p>I am animating multiple boxes using a for loop. </p>
  
  <p>The javaScript:</p>
  
  <pre><code>&lt;script&gt;
  window.onload = function(){
    $('div.test').mouseover(function(){
      for (var i = 0; i &lt; 2; i++){
        console.log(i+' Starting Loop');
  
        //Rotate box animation
        $('div.test' &amp;&amp; '.'+i).transition({
          perspective: '100px',
          rotateY: '-180deg',
          x: '-90px'
        }, 'slow',function(){
          //On completion code.
          $('div.test' &amp;&amp; '.'+i).append(' With Changed Text');
          console.log(i + 'Text has been changed');
  
          //Rotate back
          $('div.test' &amp;&amp; '.'+i).transition({
            perspective: '100px',
            rotateY: '0deg',
            x: '0px'
          }, 'slow');
        });
        console.log(i + 'finished the loop');
        alert(i + ' finished loop');
      }
    });
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And the HTML:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div class='test 0'&gt;
    Box1
  &lt;/div&gt;
  &lt;div class='test 1'&gt;
    Box2
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>It is supposed to work by making the box move, make the appropriate changes, and then move back to its original position. </p>
  
  <p>However, instead of waiting for the first animation to finish before moving on to the next iteration of the for loop, it seems to be waiting until the for loop is finished before it executes the <code>$.transition()</code> functions. </p>
  
  <p>So when the <code>$.transition()</code> functions are called, <code>i = 2</code>. Therefore the <code>$.append()</code> function is appending to an element with the class '.2', which does not exist. </p>
  
  <p>Is there any way to make sure the animations execute within the loop properly?</p>
  
  <p><strong>NOTE</strong> This is a simplified version of my real code. I would normally be appending different values for each box. I am also iterating through a list which could possibly be longer than 2. </p>
  
  <p><strong>EDIT</strong> I found a solution by recursively iterating through the array. <a href="http://jsfiddle.net/bHsL3/9/" rel="nofollow">Here it is.</a></p>