大家好,我在以下方面遇到了问题。 我有2个按钮应该打开2个模态框。第一个打开配置文件描述并且运行良好,但是第二个仅显示背景,我不明白为什么。 请参见下面的代码。 第一个脚本工作正常。 第二个不能正常工作。当我单击按钮时,会弹出深色背景,但#Pr9a模态却没有,我也不明白为什么。这两个按钮实际上在卡片内。 Pr9a模式不会弹出!
$(document).on('click', '.b77dynamic', function() {
$.ajax({
type: "POST",
url: "actions.php?action=disProfRecip",
data: "rrr=" + $(this).closest('div').attr('id'),
success: function(result) {
$('#modalProfile').html(result);
$('#myPr').modal('show');
}
})
});
$(document).on('click', '.b9ady', function() {
var rChatCut = $(this).closest('div').attr('id');
$('#recMsgEmail').val(rChatCut);// to who for php
$('#Pr9a').modal('show');
});
<button type="button" style="font-size: 12px !important;" id="b9a" class="b9ady buttonmenu toggleForms btn btn-outline-info" >Message</button>
<button type="button" style="font-size: 12px !important; " class="b77dynamic buttonmenu toggleForms btn btn-outline-info">Profile</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
<!-- Modal -->
<div class="modal fade" id="myPr" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h2 class="modal-title" id="myModalLabel">Profile</h2>
</div>
<div class="modal-body" id="modalProfile">
<?php echo $_SESSION['modalProfile']; ?>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<div class="modal fade" id="Pr9a" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">New message</h4>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="recipient-name" class="control-label">Recipient:</label>
<input type="text" class="form-control" id="recMsgEmail">
</div>
<div class="form-group">
<label for="message-text" class="control-label">Message:</label>
<textarea class="form-control" id="message-text"></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Send message</button>
</div>
</div>
</div>
</div>