在我的MVC Core项目中有以下链接:
<a asp-action="ArtictleDetailsById" asp-controller="Home" asp-route-area="Global" asp-route-id="@Model.Id" data-ajax="true" data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="ArticleDetails" class="btn btn-default">View Details</a>它按预期发送和检索数据,但不更新目标元素。更具体地说,在尝试调试时,将评估并跳过以下内容(来自jquery.unobtrusive-ajax.js):
$(element.getAttribute("data-ajax-update")).each(function (i, update) {
var top;
switch (mode) {
case "BEFORE":
top = update.firstChild;
$("<div />").html(data).contents().each(function () {
update.insertBefore(this, top);
});
break;
case "AFTER":
$("<div />").html(data).contents().each(function () {
update.appendChild(this);
});
break;
case "REPLACE-WITH":
$(update).replaceWith(data);
break;
default:
$(update).html(data);
break;
}
});但以下代码将起作用(替换.each()循环):
update = (element.getAttribute("data-ajax-update"));
$('#'+update).html(data);我想知道这是不是有一个已知的问题,是适当的修复,还是我做错了什么。我看到过去有一些关于.live()用法的问题,但这里不是这样。
https://stackoverflow.com/questions/38310338
复制相似问题