title: jquery ui datepicker inside asp.net UpdatePanel
body: <p>I have a web page, where I'm using a jQuery UI datepicker on an asp.net textbox, which is located inside an UpdatePanel. Here is a description of what I do roughly</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready( function() { $(".datepicker").datepicker(); } );
  &lt;/script&gt;
  
  &lt;asp:UpdatePanel ... &gt;
      ...
      &lt;asp:TextBox runat="server" CssClass="datepicker" /&gt;
      &lt;asp:Button runat="server" /&gt;
      ...
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>When I first load the page, everything works fine. When clicking inside the textbox, the datepicker pops up. But when I click the button, and an async postback is executed, the datepicker no longer pops up, when I click the field again.</p>
  
  <p>I know that the problem is because the UpdatePanel completely replaces all the contained HTML when it is updated, so in effect, it is a new text field, which has not been initialized with the datepicker functionality.</p>
  
  <p>I guess that I should not use $(document).ready() here to initialize my datepickers, but where is a good place to place the initialization code? Or is there a way that I can retrigger the initialization code after an AJAX update?</p>