title: How to get multiple datepickers to work with altFields?
body: <p>In my application I have a form for <code>invoices</code> which can have multiple <code>items</code>. Each item has a date consisting of an input field (where the user can enter the date in his preferred format) and a hidden field (which gets sent to the database when the form gets submitted). Each items gets added to the invoice dynamically with jQuery.</p>
  
  <pre><code>&lt;div class="item"&gt;
    &lt;input class="display_date" id="display_date_1" type="text" value="15.08.2014"&gt;
    &lt;input class="real_date" id="real_date_1" type="text" value="2014-08-15"&gt;
    ...
  &lt;/div&gt;
  
  &lt;div class="item"&gt;
    &lt;input class="display_date" id="display_date_2" type="text" value="16.08.2014"&gt;
    &lt;input class="real_date" id="real_date_2" type="text" value="2014-08-16"&gt;
    ...
  &lt;/div&gt;
  
  &lt;div class="item"&gt;
    &lt;input class="display_date" id="display_date_3" type="text" value="17.08.2014"&gt;
    &lt;input class="real_date" id="real_date_3" type="text" value="2014-08-17"&gt;
    ...
  &lt;/div&gt;
  </code></pre>
  
  <p>My question is: How can I get the <a href="http://jqueryui.com/datepicker/" rel="nofollow">datepicker</a> to work on all these (dynamically added) items?</p>
  
  <p>This is my jQuery but it doesn't work:</p>
  
  <pre><code>$(function() {
  
    $('.display_date').each(function(){
  
      $(this).datepicker({
          dateFormat: "dd M yy", // format shown to the user
          altField: "#" + $(this).attr('id'),
          altFormat: "yy-mm-dd" // format for database processing
        });
      });
  
  });
  </code></pre>
  
  <p>Thanks for any help.</p>