title: Get a reference to the anchor element of an Ajax.ActionLink at the OnSuccess handler
body: <p>Basically my question is similar or even a duplicate of <a href="https://stackoverflow.com/questions/1012599/asp-net-mvc-get-reference-to-triggerelement-in-onsuccess-function">this</a> one, except that I'm using MVC Razor. And I'm certain that the answers there are outdated since the client library currently used is jQuery / unobtrusive ajax.</p>
  
  <p>So to sum up the question, I'm trying to access the anchor element that triggered the Ajax request in the handler specified at the <code>OnSuccess</code> property of the provided <code>AjaxOptions</code>.</p>
  
  <p>Here is the <code>ActionLink</code>:</p>
  
  <pre><code>@Ajax.ActionLink("Add opening times entry", "AddOpeningTimes", 
    new { htmlPrefix = Html.HtmlPrefixFor(m =&gt; Model.OpeningTimes) },
    new AjaxOptions { UpdateTargetId = "openingTimes",
      InsertionMode =  nsertionMode.InsertAfter,
      OnSuccess = "updateHtmlPrefix" },
    new { title = "Add opening times entry" })
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function updateHtmlPrefix() {
    this.href = this.href.replace(/\d(?=]$)/, function (i) { return ++i; });
  }
  </code></pre>