title: JQuery Datepicker not updating my var correctly when a date a chosen
body: <p>I can't seem for the life of me to get this to work properly.</p>
  
  <p>When the jQuery is executed, it works fine and sets the var (text) just fine the first time.</p>
  
  <p>Then, if its called again, it keeps the original text and does not change, unless of course, I were to refresh the webpage.</p>
  
  <p>How can the code be modified, such that the var text is set to what it is supposed to be?</p>
  
  <pre><code>var sdate, text
  
  //....1)
          $(document).on('keypress', function (e){ if(e.which === 13 &amp;&amp; $('#dd').dialog('isOpen') === true) { $('.ui-state-active').click(); } }); 
          $('#dd').dialog({ autoOpen: true, modal: true, overlay: { opacity: 1.0, background: 'black' }, title: "SELECT A NEW DUE DATE", height: 235, width: 235, draggable: false, resizable: false});
  
          $('#d1').datepicker({
              onSelect: function() {
  
                  sdate = $(this).val();
  
                  text = 'THIS IS THE ORIGINAL TEXT WHEN A DATE IS SELECTED IN THE DATEPICKER'
  
                  $("#dd").dialog("close");
  
               }//end of onSelect: function() {
          });//end of datepicker
  
  
  //....2)
          $(document).on('keypress', function (e){ if(e.which === 13 &amp;&amp; $('#dd').dialog('isOpen') === true) { $('.ui-state-active').click(); } }); 
          $('#dd').dialog({ autoOpen: true, modal: true, overlay: { opacity: 1.0, background: 'black' }, title: "SELECT APPROVAL DATE", height: 235, width: 235, draggable: false, resizable: false});
  
          $('#d1').datepicker({
              onSelect: function() {
  
                  sdate = $(this).val();
  
                  text = 'THE TEXT NEVER CHANGES FOR SOME ODD REASON AND CANT SEEM TO FIGURE OUT WHY'
  
                  $("#dd").dialog("close");
  
               }//end of onSelect: function() {
          });//end of datepicker
  </code></pre>