title: Why doesn't my simple jquery UI date script setDate properly?
body: <p>I have made a little script for a payment schedule.</p>
  
  <p>On clicking a button, an input is generated. This input is a date selector input from the jquery ui framework.</p>
  
  <p>On selecting the date for the first input, if another input is generated, the starting date would be the previous date, plus 1 day.</p>
  
  <p>So far I have got about half of this working, but it seems my setDate option is not working as planned.</p>
  
  <p>If you look at the <a href="http://jsfiddle.net/rXrYy/1/" rel="nofollow"><strong>following jsfiddle you can see what is and isn't working so far</strong></a>.</p>
  
  <p>Here is the jquery code at a glance:</p>
  
  <pre><code>$('#add_payment_schedule_button').live('click',function(){
  
      // get number of schedule date inputs already...
      var schedule_count = $('.payment_schedule_date_wrap').length;
  
  
      // get previous date if there is more than 1 date box already
      if(schedule_count &gt; 0) 
      {
          var previous_date = $('#payment_schedules input.date:last').val();
          alert(previous_date);
      }
  
      // the new input var for insertion
      var payment_schedule = '&lt;div class="payment_schedule_date_wrap"&gt;&lt;input type="text" name="date['+schedule_count+']" class="date date_'+schedule_count+'" placeholder="..." /&gt;&lt;/div&gt;';
  
  
      // insert the new input into the scope
      $('#payment_schedules').append(payment_schedule);
  
  
      // load the date picker...
      $('input.date_'+schedule_count).datepicker({ dateFormat: 'dd-mm-yy', setDate: previous_date});
  
  
  });
  </code></pre>
  
  <p>As you can see from the example, if you select the datepicker, choose a date, then add another schedule input, the alert function displays the date you just picked. But it doesn't insert it into the new datepicker.</p>
  
  <p>Am I doing the selector wrong? What aren't I seeing?</p>
  
  <p>And how can I go about simply adding 1 day to the previous_date var?</p>
  
  <p>Thanks for your time.</p>