我在登台服务器上加载模态窗口时遇到问题。我的模态窗口在localhost(Apache)上加载时,无法在登台(LiteSpeed)上加载内容。奇怪的是,模态打开并显示标题,但没有内容。我检查元素时出现503错误。
暂存也不会加载图标。我认为问题出在配置的某个地方,但由于我刚开始使用Yii2,我不知道该去哪里了。
我已经创建了模态功能,如下所示:
web / js / modal.js中的modal.js
$(function(){
$(document).on('click', '.showModalButton', function(){
if ($('#modal').data('bs.modal').isShown) {
$('#modal').find('#modalContent')
.load($(this).attr('value'));
//dynamically set the header for the modal
document.getElementById('modalHeader').innerHTML = '<button type="button" class="close" ' +
'data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">×</span>' +
'</button> ' +
'<h4>' + $(this).attr('title') + '</h4>';
} else {
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
//dynamically set the header for the modal
document.getElementById('modalHeader').innerHTML = '<button type="button" class="close" ' +
'data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">×</span>' +
'</button> ' +
'<h4>' + $(this).attr('title') + '</h4>';
}
});
});
在views / layouts / main.php中设置的布局(摘录)
</footer>
<?php
Modal::begin([
'headerOptions' => [
'id' => 'modalHeader',
],
//'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
'id' => 'modal',
'size' => 'modal-lg',
//keeps from closing modal with esc key or by clicking out of the modal.
// user must click cancel or X to close
'clientOptions' => [
'backdrop' => 'static',
'keyboard' => false
],
]);
echo "<div id='modalContent'></div>";
Modal::end();
?>
<?php $this->endBody() ?>
查看索引操作(摘录)
<p>
<?= Html::a('Create FAQ',
false,
[
'class' => 'showModalButton btn btn-success',
'value' => '/index.html?r=faq/create',
'title' => 'Create FAQ',
]) ?>
</p>
当我按下按钮模式打开但没有加载表格时。
如果我错过了一些重要信息,请询问是否可以解决这个问题。
页面加载所有资产,我只在登台服务器上收到503错误。
答案 0 :(得分:1)
use yii\bootstrap\Modal;
in your Grid View
'panel' => [
'before' => Html::a('<i class="glyphicon glyphicon-plus">Open Modal</i>', ['#'], ['data-toggle' => 'modal', 'class' => 'btn btn-md btn-success', 'data-target' => '#showModal']),
'type' => GridView::TYPE_PRIMARY,
]
At the bottom add this
Modal::begin([
'id' => 'showModal',
'header' => '<center><h4 class="modal-title">Allocate Work </h4></center>',
'closeButton' => [
'label' => 'Close',
'class' => 'btn btn-danger btn-sm pull-right',
],
]);
echo Yii::$app->controller->renderPartial('allocation');
Modal::end();