我有以下BS模式
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">Large modal</button>
<div class="modal exx fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal">
<div class="modal-dialog modal-lg">
<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">Mesaj</h4>
</div>
<div class="modal-body">
<p><?php
if (isset($registration)) {
if ($registration->errors) {
foreach ($registration->errors as $error) {
echo $error;
}
}
if ($registration->messages) {
foreach ($registration->messages as $message) {
echo $message;
}
}
}
?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" aria-label="Close" data-dismiss="modal">Inchide</button>
<button type="button" class="btn btn-primary">Acasa</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
</div>
我试图在PHP代码输出内容(它的注册页面)时运行Modal
我已经阅读了BS Modal文档,但除了按钮之外我还能找到任何自动。
答案 0 :(得分:1)
如果你想在页面加载时打开模态,那么
$(document).ready(function(){
var content = $('.modal-body').find('p').html();
console.log(content); // You can see in console there is content present or not
if(content != '' || content != null ){
$('your modal').modal('show');
}
});