簡體   English   中英

創建模態時缺少yii2資產

[英]yii2 assets missing when creating modal

我知道有很多類似的問題我都試過了,但都無濟於事。 在我的模式中,資產丟失了,我也不知道該如何在哪里重新加載它們。

編輯:這是我的start-form.php:

<?php $this->registerJsFile('js/voti.js'); ?>

    <div class="box-footer">
                    <center><button id="ladeauswertung" class="btn btn-default">Auswertung Laden</button></center>
                </div>

    <div id  ='auswertungdetail' name = 'auswertungdetail'>

    <?= $auswertungdetail ?>

    </div>

單擊“ ladeauswertung”按鈕時,將執行以下JS代碼,您可以在此處看到script-file.js:

$(document).on('click', '#ladeauswertung', function ()
{
    var ausgewaehlterstandort = document.getElementById("standorte").value;
    var datum = document.getElementById("datum").value;

    $.get("index.php?r=voti/ladeauswertung&standort=" + ausgewaehlterstandort + "&datum=" + datum,
            function (jsondata)
            {
                document.getElementById("auswertungdetail").innerHTML = jsondata;
            }
    );
});

這是我的控制器中的代碼部分:

$.get("index.php?r=voti/ladeauswertung&standort=" + ausgewaehlterstandort + "&datum=" + datum,

執行以下操作:

return $this->renderAjax('auswertungdetail', ["auswertung" => $auswertung, "gesamtauswertung" => $gesamtauswertung]); 

因此在我的表單中單擊按鈕后,模態就會出現,並且在我的模態中有一個daterangepicker和一個圖表小部件include。 這些小部件在每種形式下都能很好地工作,但在模態下卻不是,因此我認為資產丟失了,但是我應該在哪里裝載它們呢?

幾天以來,請幫助我進行搜索。

您的HTML代碼:

<div id  ='auswertungdetail' name = 'auswertungdetail'>
</div>

您的Javascript代碼:

<script>
$(document).on('click', '#ladeauswertung', function ()
    {
        var ausgewaehlterstandort = document.getElementById("standorte").value;
        var datum = document.getElementById("datum").value;        
 $('#auswertungdetail').load("index.php?r=voti/ladeauswertung&standort="+ausgewaehlterstandort+"&datum="+datum").fadeIn("slow");
    }
    );

</script>

渲染普通視圖時,只需在控制器中進行編碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM