Reputation: 914
I have a problem with Bootstrap modal.
I want to show my modal with correct if condition. But it not show.
Here is my code:
<?php if (isset($_['messages']) && $_['messages'] == 'ok'): ?>
<div class="alert alert-success">
Chúc mừng quý khách đã đăng kí thành công VNPT Drive - Dịch vụ Lưu trữ và chia sẻ trực tuyến hàng đầu Việt Nam. Quý khách vui lòng đăng nhập để sử dụng dịch vụ.<br>
</div>
<!--LAM test -->
<div class="container">
<div class="modal fade" id="myModal2" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><?php echo "Title"; ?></h4>
</div>
<div class="modal-body">
<p><?php echo "LAMMMMMM"; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Đóng</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(function() {
$("#myModal2").modal();
});
</script>
This is a result.
It only show <div>Chúc mừng...bla bla...</div>
.
Here is console error:
PS: I try to add button and open my modal by click button, It's work. It only not auto show modal.
Upvotes: 0
Views: 990
Reputation: 1
Take a look at the console is there is an error message, or maybe you forget to import bootstrap.js or modal.js
Upvotes: 0
Reputation: 10148
Change $("#myModal2").modal();
to $("#myModal2").modal('show');
to open modal with jquery.
This will trigger your modal to show
Upvotes: 1