dsnhalq37505 2018-02-28 08:34
浏览 77

Yii2 - 缺少小部件 - 使用Ajax创建模式时的资产

I have searched now very long for this but no answers, please help me. I'm using the highchart-widget from 2amigos in yii2. When I'm creating a view in my controller via "render" the chart shows Asset inlcuded

and as you can see on the picture on the right the asset is included in the source of the network -> "b732256a - highcharts.src.js"

BUT NOW COMES THE PROBLEM, when I'm rendering the view with "renderAjax" and insert the view in an existing HTML document with ajax -> take a look at my javascript code: the the asset "b732256a - highcharts.src.js" is missing take a look at this foto

Asset Missing

But when i access the action direct via browser:

index.php?r=bewt/ladeauswertung&standort=&datum=

it works with renderAjax and render, there is just a problem when i bind the view in an existing html document. im using this routine, to bind the view in an existing html document

document.getElementById("auswertungdetail").innerHTML = jsondata;

What you need to know about my code. on a html-page there is a button, when the user press this button im calling the following javascript code, and the chart should show up without reloading the whole page

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

in my controller im rendering the view:

       function actionLadeauswertung($standort, $datum)
    {

//some algorithm that do smth with $standort and $datum, not important
    $auswertung = 5;
    $gesamtauswertung = 10;

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

and here ist the view which i render in the controller above:

<?php

use dosamigos\highcharts\HighCharts;

?>


         <?php echo
HighCharts::widget([
    'clientOptions' => [
        'chart' => [
                'type' => 'bar'
        ],
        'title' => [
             'text' => 'Fruit Consumption'
             ],
        'xAxis' => [
            'categories' => [
                'Apples',
                'Bananas',
            ]
        ],
        'yAxis' => [
            'title' => [
                'text' => 'Fruit eaten'
            ]
        ],
        'series' => [
            ['name' => 'Jane', 'data' => [1, 0, 4]],
            ['name' => 'John', 'data' => [5, 7, 3]]
        ]
    ]
]);
?>

and in my view im calling the 2amigos highchart, it works perfectly with "render" but i wanted to add the view where the highchart is included dynamically when a button is pressed so have to use renderAjax.

PLEASE HELP!!!!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误