title: ASP.NET MVC: jQuery UI DatePicker Set minDate and maxDate from Model on AJAX Loaded Page
body: <p>I have a dialog form that pops up and its content is loaded using the jQuery load function.  On that ajax loaded page there is a jQuery UI datepicker and in the Model that I pass to the view, I have MinDate and MaxDate properties that are used to set the min and max dates of the datepicker.  On a non-ajax page I usually do something like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function () {
       var model = @(Model.ToJson());
  
          $('.date').datepicker('option', 'minDate', new Date(parseInt(model.MinDate.substr(6))));
          $('.date').datepicker('option', 'maxDate', new Date(parseInt(model.MaxDate.substr(6))));
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The problem is that if I include any javascript in the view that is loaded from the jQuery load function, it is stripped out and not executed.  So, if I included the above code to specify the min and max dates for the datepicker in the dialog form doesn't work.</p>
  
  <p>How can I specify min and max dates for a jQuery UI datepicker where the datepicker is being loaded via ajax and the min and max dates come from the model?</p>