{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8702","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8702/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8702/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8702/events","html_url":"https://github.com/yiisoft/yii2/issues/8702","id":86163933,"number":8702,"title":"Inline registering of javascript during PJAX calls uses document.on('ready') instead of document.on('ready pjax:end')","user":{"login":"sergeantjonas","id":10808486,"avatar_url":"https://avatars.githubusercontent.com/u/10808486?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeantjonas","html_url":"https://github.com/sergeantjonas","followers_url":"https://api.github.com/users/sergeantjonas/followers","following_url":"https://api.github.com/users/sergeantjonas/following{/other_user}","gists_url":"https://api.github.com/users/sergeantjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeantjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeantjonas/subscriptions","organizations_url":"https://api.github.com/users/sergeantjonas/orgs","repos_url":"https://api.github.com/users/sergeantjonas/repos","events_url":"https://api.github.com/users/sergeantjonas/events{/privacy}","received_events_url":"https://api.github.com/users/sergeantjonas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/13","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.5","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/13/labels","id":1000704,"number":13,"title":"2.0.5","description":"","creator":{"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},"open_issues":61,"closed_issues":62,"state":"open","created_at":"2015-03-01T16:03:07Z","updated_at":"2015-06-08T18:34:10Z","due_on":"2015-07-26T04:00:00Z","closed_at":null},"comments":5,"created_at":"2015-06-08T12:49:17Z","updated_at":"2015-06-08T21:03:39Z","closed_at":null,"body":"I recently changed my application to use pjax requests, but today I stumbled upon an issue while using inline javascript ($this->registerJS). The javascript is not being executed as it's wrapped in a document.ready. After doing some digging it appears the root cause lies all the way in the web/View.php file.\r\n\r\nLine 565 has the following:\r\n````php\r\n$js = \"jQuery(document).ready(function () {\\n\" . implode(\"\\n\", $this->js[self::POS_READY]) . \"\\n});\";\r\n````\r\n\r\nIt should be:\r\n\r\n````php\r\n$js = \"jQuery(document).on('ready pjax:end', function () {\\n\" . implode(\"\\n\", $this->js[self::POS_READY]) . \"\\n});\";\r\n````\r\n\r\nBut then even if no PJAX is being used the pjax:end will be there, although I don't think that causes issues, there is probably a cleaner fix (checking for the PJAX request header?)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/110139937","html_url":"https://github.com/yiisoft/yii2/issues/8702#issuecomment-110139937","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8702","id":110139937,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T21:03:39Z","updated_at":"2015-06-08T21:03:39Z","body":"I guess if PJAX failed, there's nothing to trigger. Also what if I'll do PJAX reload of many fragments. Would that trigger event more than once and cause script to be executed again and again?"}}