I’ve tried to inspect the AjaxContext that ASP.NET-MVC uses on for instance Ajax Actionlinks and their onSucces, onComplete etc. clientside functions. But I don’t understand very much of it… Where is the documentation on this thing?
Does anybody know how to I get the ‘target’ or ‘srcElement’ (e.target or window.event.srcElement) when I am in a onSuccess or onComplete javascript event?
<%=Ajax.ActionLink(
"LinkText", "Action", New With {.Controller = "ControllerName"},
New AjaxOptions With {
.UpdateTargetId = "divElement",
.OnSuccess = "function(ajaxContext) {console.log(ajaxContext);}"
}) %>
Which results in:
<a
href="/Popout/ApplicationCodePopout"
onclick="Sys.Mvc.AsyncHyperlink.handleClick(
this, new Sys.UI.DomEvent(event),
{
insertionMode: Sys.Mvc.InsertionMode.replace,
updateTargetId: 'divElement',
onSuccess: Function.createDelegate(this,
function(ajaxContext) {console.log(ajaxContext);}
)
}
);"
>LinkText</a>
You could change the onSuccess method to this:
(Note the debugger keyword)
Then you can break into it using VS2008 (assuming IE, if you’re using Firefox, then install Firebug as Jake said) and then you can use the quick watch window (in VS or equivalent in Firebug etc) to view the object and it’s properties/ methods etc.
As for some documentation, check out this link to see the code comments, and this article for some more information.