我不知道如何向模态提交数据-例如:
$('#exampleModal').on('shown.bs.modal', function () {
var userID = $(this).data('userId');
$('#passUser').trigger('focus')
})
该示例直接从引导程序文档中获取,但传递数据和表单除外。
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" id="passUser" data-userId="@Html.DisplayFor(modelItem => item.Id)">
Launch demo modal
</button>
按钮具有正确的ID值,但我不知道如何传递它,甚至不传递某些文本到模式。
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Show Value userID!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
使用类似的东西:
$("#exampleModal .modal-body").html($("#passUser").data("userId"))
答案 1 :(得分:0)