簡體   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