title: ASP.NET MVC.NET JQueryUI datepicker inside a div loaded/updated with ajax.actionlink
body: <p>I'm trying to incorporate jqueryUI's datepicker inside a partialview like this:</p>
  
  <pre><code>  &lt;% using (Ajax.BeginForm("/EditData", 
                              new AjaxOptions { HttpMethod = "POST", 
                                               UpdateTargetId = "div1"   }))
    {%&gt;
      Date: 
     &lt;%= Html.TextBox("date", String.Format("{0:g}", Model.date), new { id = "datePicker"})%&gt;
     &lt;% } %&gt;
  
          &lt;script type="text/javascript"&gt;
  
          $(function() {
              $("#datePicker").datepicker();
          });
          &lt;/script&gt;
  </code></pre>
  
  <p>When I directly call the url to this partial view, so it renders only this view the datepicker works perfectly. (For the purpose of testing this I added the needed jquery and jqueryui script and css references directly to the partial view)</p>
  
  <p>But if I use a <code>Ajax.Actionlink</code> to load this partial view inside a div (called div2, submitting the above form should update div1)  like this:</p>
  
  <pre><code>&lt;div id="div1"&gt;
      &lt;%= Ajax.ActionLink("Edit", "/EditData", new { id = Model.id }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "div2" } )%&gt;                  
  
  &lt;/div&gt;
  &lt;div2&gt;placeholder for the form&lt;/div&gt;
  </code></pre>
  
  <p>The datepicker won't appear anymore.
  My best guess is the javascript included in the loaded html doesn't get executed,</p>
  
  <pre><code>($(document).ready(function() {
          $("#datepicker").datepicker();
      }); doesnt work either
  </code></pre>
  
  <p>If that's the case how and where should I call the <code>$("datepicker").datepicker();</code> ?
  (putting it in the ajaxoptions of the <code>ajax.actionlink</code> as <code>oncomplete = "$(function() {
              $('#datepicker').datepicker();});"</code> still doesnt work.</p>
  
  <p>If that's not the case, then where's my problem?</p>