yii 页面加载完成后弹出模态框

时间:2022-05-03 20:45:48
<?php
$js = <<<JS
$('#page-modal').modal('show');//页面加载完显示模态框
$('.modal-dialog').css('width', '1038px');//设置模态框宽度
JS;
$this->registerJs($js);
use yii\bootstrap\Modal; Modal::begin([
'id' => 'page-modal',
'header' => '<h3 align="center">this is title</h3>',
'footer' => '<div align="center"><a href="#" align="center" class="btn btn-primary" data-dismiss="modal">好的,我知道了</a></div>',
'options'=>[
'data-backdrop'=>'static',//点击空白处不关闭弹窗
'data-keyboard'=>false,
'data-show'=>true,
],
'size'=>'modal-lg',
]); echo "this is content"; Modal::end();
?> <?= Html::a('点击显示模态框', '#', ['class' => 'btn btn-warning', 'data-toggle' => 'modal', 'data-target' => '#page-modal'])?>