MVC Ajax ActionLink 替换了整个 bootstrap modal-body

MVC Ajax ActionLink replaces the entire bootstrap modal-body

下面的 Ajax.ActionLink 有一个空的 AjaxOptions。令人惊讶的是,它会自动将 ajax 响应渲染到模式中并替换整个 .modal-body 元素。我的意图是将响应呈现到 #ItemCommentModalBody div 中。无论我如何设置 UpdateTargetId 和 InsertionMode,即使 AjaxOptions 为空,响应也将替换整个 .modal-body div。这是一个错误吗?模态由 bootstrap.

触发
@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>

其实好像跟data_toggle = "modal"属性有关。如果您从操作中删除它 link 而是触发一个显示模态的 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');
}