{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/3680","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/3680/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/3680/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/3680/events","html_url":"https://github.com/yiisoft/yii2/issues/3680","id":34835733,"number":3680,"title":"pjax 更新时引入js css 文件问题","user":{"login":"pk8est","id":5977586,"avatar_url":"https://avatars.githubusercontent.com/u/5977586?v=3","gravatar_id":"","url":"https://api.github.com/users/pk8est","html_url":"https://github.com/pk8est","followers_url":"https://api.github.com/users/pk8est/followers","following_url":"https://api.github.com/users/pk8est/following{/other_user}","gists_url":"https://api.github.com/users/pk8est/gists{/gist_id}","starred_url":"https://api.github.com/users/pk8est/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pk8est/subscriptions","organizations_url":"https://api.github.com/users/pk8est/orgs","repos_url":"https://api.github.com/users/pk8est/repos","events_url":"https://api.github.com/users/pk8est/events{/privacy}","received_events_url":"https://api.github.com/users/pk8est/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status%3Ato+be+verified","name":"status:to be verified","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"qiangxue","id":993322,"avatar_url":"https://avatars.githubusercontent.com/u/993322?v=3","gravatar_id":"","url":"https://api.github.com/users/qiangxue","html_url":"https://github.com/qiangxue","followers_url":"https://api.github.com/users/qiangxue/followers","following_url":"https://api.github.com/users/qiangxue/following{/other_user}","gists_url":"https://api.github.com/users/qiangxue/gists{/gist_id}","starred_url":"https://api.github.com/users/qiangxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiangxue/subscriptions","organizations_url":"https://api.github.com/users/qiangxue/orgs","repos_url":"https://api.github.com/users/qiangxue/repos","events_url":"https://api.github.com/users/qiangxue/events{/privacy}","received_events_url":"https://api.github.com/users/qiangxue/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2014-06-03T06:38:20Z","updated_at":"2015-01-03T17:31:35Z","closed_at":null,"body":"1、pjax.js 获取到后台数据后，用 jqery.parseHTML 对数据进行了解析，\r\n其中，context 包括 后台返回的body与及 不包括src属性的script标签(比如：jQuery('#w1').yiiGridView(...))；scripts包括有src属性的script标签(如 jqery.js, yii.js, yii.gridView.js)。\r\n2、把context的内容插入到要更新的容器内\r\n3、把scripts内的文件插入到document.head（已经加载过的会过滤掉）\r\n4、因为第3步在第2步后面执行，导致第2步时context 中的代码找不到第3步中要加载的文件（虽然js代码都是放在jQuery(document).ready(...) 内，但因为这是通过ajax请求内容，返回内容后ready已经生效，而我们的页面是通过js插入页面的。所以在插入的同时会触发所有在ready内的代码，我是这样想的，不知道对不对）。\r\n比如：先加载 jQuery('#w0').yiiGridView(...)，然后才是加载 yii.gridView.js，\r\n最后导致TypeError: jQuery(...).yiiGridView is not a function.\r\n5、而且。因为是异步的问题，就算第3步比第2步先执行，也有可能出现上述问题\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/68602489","html_url":"https://github.com/yiisoft/yii2/issues/3680#issuecomment-68602489","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/3680","id":68602489,"user":{"login":"llfm","id":8844652,"avatar_url":"https://avatars.githubusercontent.com/u/8844652?v=3","gravatar_id":"","url":"https://api.github.com/users/llfm","html_url":"https://github.com/llfm","followers_url":"https://api.github.com/users/llfm/followers","following_url":"https://api.github.com/users/llfm/following{/other_user}","gists_url":"https://api.github.com/users/llfm/gists{/gist_id}","starred_url":"https://api.github.com/users/llfm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llfm/subscriptions","organizations_url":"https://api.github.com/users/llfm/orgs","repos_url":"https://api.github.com/users/llfm/repos","events_url":"https://api.github.com/users/llfm/events{/privacy}","received_events_url":"https://api.github.com/users/llfm/received_events","type":"User","site_admin":false},"created_at":"2015-01-03T17:31:35Z","updated_at":"2015-01-03T17:31:35Z","body":"I could only understand some part of @qiansen1386 said. But maybe this is related to this [issue](https://github.com/yiisoft/yii2/issues/6655)"}}