title: Execute Script after append element from ajax callback
body: <p>From an ajax call i get a div and a script that populate the div with another ajax call.
  the problem is that when the script is run it can't find the div.</p>
  
  <p>this is the razor code :</p>
  
  <pre><code>@model int
  
  @{
      var id = string.Format("riga_{0}", Model);
  }
  &lt;div id="@id"&gt;
      wait please...
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      $("#" + "@id").load("/RigaMovimento/Details/@Model");
  &lt;/script&gt;
  </code></pre>
  
  <p>that generate this :</p>
  
  <pre><code>&lt;div id="riga_79"&gt;
      wait please...
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      $("#" + "riga_79").load("/RigaMovimento/Details/79");
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>ANSWER</strong></p>
  
  <p>is not beautifull, but works :</p>
  
  <pre><code>@using (Ajax.BeginForm("Create", new { movimentoId = Model.MovimentoId }, new AjaxOptions() { InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "righe", OnSuccess = "run_after" }))
  {
      &lt;input type="submit" value="New" /&gt;
  }
  
  &lt;script type="text/javascript"&gt;
      var run_after;
  &lt;/script&gt;
  </code></pre>
  
  <p>the create view :</p>
  
  <pre><code>@model int
  
  @{
      var id = string.Format("riga_{0}", Model);
  }
  
  &lt;div id="@id"&gt;
      wait please...
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      run_after = function () {
          $('#' + '@id').load(
              "/RigaMovimento/Details/@Model", 
              null, 
              function() { $('#' + '@id').fadeIn('slow'); } );
      }
  &lt;/script&gt;
  </code></pre>