JS or CSS registered with registerJS, registerJSFile etc will not work in renderDynamic. This problem causes, that it is not possible to use any widgets in renderDynamic
on a cached page which has JavaScript or CSS assets. This issue is basically #16051 re-opened with simple step-step reproducing.
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
cd basic
views/site/index.php
:$this->renderDynamic('$this->registerJs("alert(\'JS started\')");');
php yii serve --port=8888
<script src="<script>jQuery(function ($) {
alert('JS started')
});</script>
behaviors
in controllers/SiteController.php
:'indexCache' => [
'class' => 'yii\filters\PageCache',
'only' => ['index'],
'duration' => 86400, // 1 day
'enabled' => true,
],
The registered JavaScript should appear in the HTML page.
What do you get instead?All Javascript registered in renderDynamic is missing.
Additional info Q A Yii version 2.0.29 PHP version PHP 7.2.24-1+ubuntu16.04.1+deb.sury.org+1 Operating system Ubuntu 16.04RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4