繁体   English   中英

Yii2-模态未加载内容

[英]Yii2 - Modal not loading content

我在登台服务器上加载模式窗口时遇到问题。 我的模态窗口在本地主机(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">&times;</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">&times;</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错误。

这是本地主机上的工作模式

这是登台服务器上的非工作模式

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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM