[英]php echo modal doesn't work
i was trying to do is checking the user have enter any room before if they didnt leave the room they cant enter new room. 我试图做的是检查用户是否进入了任何房间,如果他们没有离开房间,他们就不能进入新房间。 but now i my modal wont show up. 但是现在我我的模态不会出现。 Anything i was doing wrong? 我做错了什么吗?
if($checkUser==0){
echo "<script>$('#myModal').modal('show');</script>
<div class='modal fade' id='myModal' role='dialog'>
<div class='modal-dialog modal-lg'>
<div class='modal-content'>
<div class='modal-body'>
<p>You didn't leave previous chatroom</p>
</div>
<div class='modal-footer'>
<a href='index.php'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Leave</button>
</a>
</div>
</div>
</div>
</div>";
}
if($checkUser==0){
echo "<script>$(document).ready(function(){ $('#myModal').modal('show'); });</script>
<div class='modal fade' id='myModal' role='dialog'>
<div class='modal-dialog modal-lg'>
<div class='modal-content'>
<div class='modal-body'>
<p>You didn't leave previous chatroom</p>
</div>
<div class='modal-footer'>
<a href='index.php'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Leave</button>
</a>
</div>
</div>
</div>
</div>";
}
Add $('#myModal').modal('show');
添加$('#myModal').modal('show');
into $(document).ready();
放入$(document).ready();
because at the time when js loaded #myModel
does not loaded into DOM. 因为在js加载时#myModel
尚未加载到DOM中。 Make sure to load Jquery before that 确保在此之前加载Jquery
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.