title: change the second datepickers minDate when selecting date from another datapicker
body: <p>I' m using jquery ui datepicker.</p>
  
  <p>I have two datepicker on the page, from and to datepickers</p>
  
  <p>when i select a date in one datepicker i update the max and min date to the second datepicker.</p>
  
  <p>my problem is that just before it close(hide) the seleted datepicker,
  it show the second datepicker instead of the first one (just when i update the min date of the second datepicker) and then close it.</p>
  
  <p>why does it show the second datepicker when i update the min date from the other datepicker?</p>
  
  <p>how can i hide the datepicker before i update the second datepicker?</p>
  
  <pre><code> &lt;!doctype html&gt;
  &lt;html &gt;
  &lt;head&gt;
  
    &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"&gt;
    &lt;script src="//code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
    &lt;script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;input name="fromDateCalendar" type="text" value="10/12/2013" id="fromDateCalendar" style="width:100px;" /&gt;     
  
   &lt;input name="toDateCalendar" type="text" value="09/01/2014" id="toDateCalendar" style="width:100px;" /&gt;    
  
  &lt;script&gt;
  
      $(function () {
          $('#fromDateCalendar').datepicker({
              onSelect: function (date) {change1(date);}});
  
          $("#toDateCalendar").datepicker({
              onSelect: function (date) {change2(date);}, maxDate: '0' });
      });
  
      function change1(date) {
          $('#toDateCalendar').datepicker('option', 'minDate', date);}
  
      function change2(date) {
          $('#fromDateCalendar').datepicker('option', 'maxDate', date);}
  
  
  &lt;/script&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>