1

以下の Ajax.ActionLink には、空の AjaxOptions があります。驚くべきことに、それは自動的に ajax レスポンスをモーダルにレンダリングし、.modal-body 要素全体を置き換えます。私の意図は、応答を #ItemCommentModalBody div にレンダリングすることです。UpdateTargetId と InsertionMode をどのように設定しても、AjaxOptions が空の場合でも、.modal-body 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>

4

1 に答える 1

1

実際には 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 属性に関連付けられている show modal 関数をトリガーするだけです。

function showModal() {
    $('#ItemCommentModal').modal('show');
}
于 2016-09-01T18:41:30.123 に答える