title: How do run javascript after loading PartialView in ASP.NET MVC?
body: <p>I'm trying to get jQuery plug-in meioMask to work in a MVC Partial View.</p>
  
  <p>As a trial, the following works:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript" src="jquery-1.8.3.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="jquery.meio.mask.min.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      jQuery(function($) {
          $('#StartTimeText').setMask('time');
  });
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;input type="text" id="StartTimeText" /&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>The text edit box gets a mask edit applied. However, my text edit box is in a MVC partial view that gets shown when user clicks on an item in the main view. In the main view's <code>&lt;head&gt;</code> I added the following:</p>
  
  <pre><code>&lt;script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.meio.mask.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>In <code>CustomFormPartialView.cshtml</code>, I have the following:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      jQuery.ajax(
        function ($) {
          $('#StartTimeText').setMask('time');
        }
      );
  &lt;/script&gt;
  
  &lt;input type="text" id="StartTimeText" /&gt;
  </code></pre>
  
  <p>But the text box remains a regular text box with no edit mask applied. I assume this is because the setMask function isn't getting run. I've tried using <code>jQuery.get</code> and <code>jQuery.post</code> as well, none of them made any difference.</p>
  
  <p>Sorry if this has already been asked, I've tried other solutions without any luck. I'm a bit new in this area, so if someone can post as complete code example as possible it'll be greatly appreciated. Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>Following JasCav's suggestion, I've put the following in the <code>&lt;head&gt;</code> section of the file. As far as I can tell, the ajax function isn't getting run at all. This is using DevExpress's MVC Scheduler if that's any help. I'm not getting any errors in FireBug.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    jQuery.ajax({
      url: '/WebTMS_MVC/Calendar/SchedulerPartial',
      type: 'POST',
      success: function (data, textStatus, xhr) {
        $('#StartTimeText').setMask('time');
      }
    });
  &lt;/script&gt; 
  </code></pre>