在Yii2中使用Pjax导致Yii2内联脚本载入失败的原因分析,yii2pjax
当我用defunkt/jquery-pjax载入Yii2的ActiveForm时发生一个错误,正常情况下是
ActiveForm的两个js应该先载入,而实际情况是
typeError:JQuery(...).yiiActiveForm is not a function。
在github的issues对这个问题已经讨论并得到了解决。
Pjax首先通过html()执行内联的<script>,然后才通过executeScriptTags()执行带着src的<script>,所以导致找不到yiiActiveForm。Pjax作者拒绝使用JQuery.getScript()解决这个问题,因为安全原因函数使用eval不符合CSP (Content Security Policy)</script>
以上所述给大家介绍了在Yii2中使用Pjax导致Yii2内联脚本载入失败的原因分析的相关资料,希望对大家以上帮助!
您可能感兴趣的文章:
- 从零开始学YII2框架(六)高级应用程序模板
- 从零开始学YII2框架(五)快速生成代码工具 Gii 的使用
- 从零开始学YII2框架(四)扩展插件yii2-kartikgii
- 从零开始学YII2框架(三)扩展插件yii2-gird
- 从零开始学YII2框架(二)通过 Composer 安装扩展插件

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor