title: Associate buttons and click actions in a loop
body: <p>I am trying to associate several click actions to several buttons, in jQuery. I am using a for loop to browse all the buttons.</p>
  
  <p>I tried something like that :</p>
  
  <pre><code>var realThis = $(this);
  
  // ...
  
  for (var i = 0; i &lt; buttons.length; i++) {
      if (typeof(buttons[i].callback) !== 'undefined')
          $('#' + buttons[i].id).click(function(){ 
              buttons[i].callback(realThis.getFormValues()); 
          });
  }
  </code></pre>
  
  <p>I got a warning from my editing software :</p>
  
  <blockquote>
    <p>Mutable variable is accessible from closure</p>
  </blockquote>
  
  <p>I tried several things without any success.</p>
  
  <p>Any help here ?</p>