我需要将用户名传递到引导模式窗口并在模式窗口中显示传递的名称。
例如,
如果我通过jawa,模态将显示类似“这是jawa”的内容
最佳答案
我们需要在您的按钮中添加属性数据 ID,如下所示,
<button type="button" data-toggle="modal" data-target="##myModal" data-id="jawa">Delete</button>
此 JS 函数将在打开 boostrap 模态窗口之前调用。在该函数中,我们可以获取 data-id 属性值,然后我们可以根据获取值编写代码。请参阅下面的代码,
<script type="text/javascript">
$('#myModal').on('show.bs.modal', function(event) {
var userName = $(event.relatedTarget).data('id');
$("#modalText").html("You are going to be deleted" + userName);
});
</script>
这是模态窗口代码,
<div id="myModal" class="modal fade" role="dialog" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="cancelModal">Google Map</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="modalText"></div>
</div>
<div class="modal-footer">
<a href="" target="_blank" id="mapLink">Open in new tab</a>
</div>
</div>
</div>
</div>
谢谢
关于coldfusion - 如何将值传递到引导模式窗口并显示动态内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52568602/