下面的Ajax.ActionLink有一个空的AjaxOptions。令人惊讶的是,它会自动地将ajax响应呈现到模型中,并替换整个. modal元素。我的目的是将响应呈现到#ItemCommentModalBody div中。无论我如何设置UpdateTargetId和InsertionMode,即使是空的AjaxOptions,响应还是会替换整个. matter div。这是个虫子吗?该模态是由引导触发的。
@Ajax.ActionLink("Add a comment", "AddComment", "Document", new { area = "", itemId = Model.ItemId }, new AjaxOptions { }, new { @class = "btn btn-warning", data_toggle = "modal", data_target = "#ItemCommentModal" })
<div id="ItemCommentModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="lblItemCommentModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div id ="ItemCommentModalBody">
</div>
</div>
</div>
</div>
发布于 2016-09-01 18:41:30
实际上,它似乎与data_toggle = "modal“属性有关。如果您从操作链接中删除它,而触发一个显示模式的OnSuccess事件,那么一切都会正常工作。
@Ajax.ActionLink("Add a comment", "AddComment", "Document",
new { area = "", itemId = Model.ItemId },
new AjaxOptions { UpdateTargetId = "ItemCommentModalBody", OnSuccess = "showModal" },
new { @class = "btn btn-warning" })showModal函数将简单地触发通常绑定到data_toggle属性的显示模式函数。
function showModal() {
$('#ItemCommentModal').modal('show');
}https://stackoverflow.com/questions/28667163
复制相似问题