Cause Analysis of Yii2 inline Script Loading failure caused by Pjax in Yii2, yii2pjax

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.