Cause Analysis of Yii2 inline Script Loading failure caused by Pjax in Yii2, yii2pjax
An error occurs when I use defunkt/jquery-pjax to load the ActiveForm of Yii2. Normally
The two js codes of ActiveForm should be loaded first, but the actual situation is:
TypeError: JQuery (...). yiiActiveForm is not a function.
This issue has been discussed and resolved in issues on github.
Pjax first executes the inline <script> through html () and then executes the <script> with src through executeScriptTags (), so the yiiActiveForm cannot be found. Pjax authors refuse to use JQuery. getScript () to solve this problem, because the function uses eval for Security reasons and does not comply with the CSP (Content Security Policy)
The above section describes the analysis of the causes of failed loading of Yii2 inline scripts using Pjax in Yii2. We hope to help you with the above!
Articles you may be interested in:
- Learning YII2 framework (6) advanced application templates from scratch
- Learn how to use YII2 framework (5) quick code generation tool Gii from scratch
- YII2 framework (iv) Extension plug-in yii2-kartikgii from scratch
- YII2 framework (iii) Extension plug-in yii2-gird from scratch
- YII2 framework from scratch (2) install extension plug-ins through Composer