我无法通过加载相应的VIEW来打开Bootstrap模式。你能救我吗?
示例:当只访问地址 index.php?r = client / base 时,我想在屏幕上弹出一个弹出窗口。
完整页面摘要
<?php
use yii\helpers\Html;
use yii\grid\GridView;
?>
<div class="visit-index">
<div class="row">
<div class="col-md-6"><h1><?= Html::encode($this->title) ?></h1></div>
<div class="col-md-6"><span class="pull-right" style="top: 15px;position: relative;"><?php echo $this->render('/base/_menu'); ?></span></div>
</div>
<hr/>
<div class="row">
<div class="col-md-7"><?php echo $this->render('_filter', ['model' => $searchModel]); ?></div>
<div class="col-md-5"><?= Html::a('<span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span> Link para Visitas Antigas', ['/visits/visits/index'], ['class' => 'btn btn-default pull-right']) ?></div>
</div>
<br/>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
<script>
function birthdays(){
$.ajax({
type:'POST',
url:'index.php?r=/client/base/modal_birthdays',
success: function(data)
{
$('#myModal').html(data);
$('#myModal').modal();
}
});
}
</script>
<div class="panel panel-default">
<div class="panel-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'id',
'headerOptions' => ['class' => 'text-center'],
'contentOptions'=>['style'=>'width: 3%;text-align:center'],
],
'observation:ntext',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {delete}',
'contentOptions'=>['style'=>'width: 8%;text-align:center'],
'headerOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>
答案 0 :(得分:1)
$(function() {
if ( document.location.href.indexOf('index.php?r=/client/base/modal_birthdays') > -1 ) {
$('#myModal').focus();
}
});
此jquery代码应将URL检测为字符串,然后设置focus
(打开)您的模态。如果你发布完整的HTML代码和所有内容,它会更容易帮助你。