【发布时间】:2013-05-09 04:29:47
【问题描述】:
基本上,我的问题与this 的问题相似甚至重复,只是我使用的是 MVC Razor。而且我确信那里的答案已经过时,因为当前使用的客户端库是 jQuery / unobtrusive ajax。
总结一下这个问题,我试图访问在提供的AjaxOptions 的OnSuccess 属性中指定的处理程序中触发Ajax 请求的锚元素。
这里是ActionLink:
@Ajax.ActionLink("Add opening times entry", "AddOpeningTimes",
new { htmlPrefix = Html.HtmlPrefixFor(m => Model.OpeningTimes) },
new AjaxOptions { UpdateTargetId = "openingTimes",
InsertionMode = nsertionMode.InsertAfter,
OnSuccess = "updateHtmlPrefix" },
new { title = "Add opening times entry" })
JS:
function updateHtmlPrefix() {
this.href = this.href.replace(/\d(?=]$)/, function (i) { return ++i; });
}
【问题讨论】:
标签: ajax asp.net-mvc razor