Heim  >  Artikel  >  php教程  >  在Yii2中使用Pjax导致Yii2内联脚本载入失败的问题,yii2pjax

在Yii2中使用Pjax导致Yii2内联脚本载入失败的问题,yii2pjax

WBOY
WBOYOriginal
2016-06-13 08:45:08804Durchsuche

在Yii2中使用Pjax导致Yii2内联脚本载入失败的问题,yii2pjax

  当我用defunkt/jquery-pjax载入Yii2的<strong>ActiveForm</strong>时发生一个错误,正常情况下是

<strong>ActiveForm</strong>的两个js应该先载入,而实际情况是

typeError:JQuery(...).yiiActiveForm is not a function

在github的issues对这个问题已经讨论并得到了解决。

  Pjax首先通过html()执行内联的<script>,然后才通过executeScriptTags()执行带着src的<script>,所以导致找不到</script>yiiActiveForm。Pjax作者拒绝使用JQuery.getScript()解决这个问题,因为安全原因函数使用eval不符合CSP (Content Security Policy)

  Yii2的一个参与者修改了Pjax,使Pjax可以在Yii2良好的工作hiqdev/jquery-pjax

  亲测没问题。

 

 

 

 

 

的的

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn