{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/9040","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/9040/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/9040/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/9040/events","html_url":"https://github.com/yiisoft/yii2/issues/9040","id":93683226,"number":9040,"title":"Refreshing Listview inside modal dialog using Pjax","user":{"login":"re1naldo","id":5090929,"avatar_url":"https://avatars.githubusercontent.com/u/5090929?v=3","gravatar_id":"","url":"https://api.github.com/users/re1naldo","html_url":"https://github.com/re1naldo","followers_url":"https://api.github.com/users/re1naldo/followers","following_url":"https://api.github.com/users/re1naldo/following{/other_user}","gists_url":"https://api.github.com/users/re1naldo/gists{/gist_id}","starred_url":"https://api.github.com/users/re1naldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/re1naldo/subscriptions","organizations_url":"https://api.github.com/users/re1naldo/orgs","repos_url":"https://api.github.com/users/re1naldo/repos","events_url":"https://api.github.com/users/re1naldo/events{/privacy}","received_events_url":"https://api.github.com/users/re1naldo/received_events","type":"User","site_admin":false},"labels":[{"id":225521613,"url":"https://api.github.com/repos/yiisoft/yii2/labels/feature:pjax","name":"feature:pjax","color":"c7def8","default":false},{"id":38412944,"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:to%20be%20verified","name":"status:to be verified","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars.githubusercontent.com/u/4499203?v=3","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false},"assignees":[{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars.githubusercontent.com/u/4499203?v=3","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false}],"milestone":null,"comments":20,"created_at":"2015-07-08T03:35:07Z","updated_at":"2016-10-31T13:09:44Z","closed_at":"2016-10-31T12:59:42Z","body":"I have a Listview that is rendered inside a modal dialog:\n\n```\n<?php Pjax::begin([\n    'id' => 'image-list',\n    'timeout' => Yii::$app->params['timeout'], \n    'enablePushState' => false        \n]); ?>\n\n        <?= ListView::widget([\n            'dataProvider' => $dataProvider,          \n            'options' => ['class' => 'list-view'],          \n            'itemView' => function ($model, $key, $index, $widget) {\n                $path = $model->getImage();\n                $size = $model->getImageSize(100, 'H');\n\n                return Html::a(Html::img($path, [\n                        'width' => $size['width'],\n                        'height' => $size['height'],\n                    ]), $path).\n                    Html::a('<i class=\"glyphicon glyphicon-trash\"></i>', '#', [\n                        'class' => 'arr-img pull-left',\n                        'title' => 'Delete',\n                        'onclick' => \"\n                            if (confirm('Are you sure you want to delete this image?') == true) {                            \n                                $.ajax({            \n                                    type: 'POST',\n                                    cache: false,\n                                    url: '\" .Yii::$app->urlManager->createUrl(['arrangement-image/delete', 'id' => $model->id]). \"',\n                                    success: function(response) {\n                                        $.pjax.reload({container: '#image-list', timeout: \" .Yii::$app->params['timeout']. \"});\n                                    }\n                                });\n                            }\n\n                            return false;\n                        \"\n                    ]);\n            },\n        ]) ?>\n\n<?php Pjax::end(); ?>\n```\n\nThat Listview is rendered via ajax request:\n\n```\n'image' => function ($url, $model) {\n    return Html::a('<i class=\"glyphicon glyphicon-picture\"></i>', '#', [\n         'title' => 'View Images',\n          'onclick' => \"\n               $('#image-modal').modal('show');\n\n               $.ajax({            \n                  type: 'POST',\n                  cache: false,\n                  url: '\" .Yii::$app->urlManager->createUrl(['arrangement-image/index', 'id' => $model->id]). \"',\n                  success: function(response) {\n                        $('#image-modal .modal-body').html(response);\n                  },\n              });\n\n              return false;\n       \",\n  ]);                            \n}\n```\n\nThe data loading and pagination work fine, but when I tried to refresh Listview using `$.pjax.reload`, the whole page was refreshed and modal dialog was closed. This doesn't happen when I render the Listview without modal dialog.\n\nThere are other people ([Thread 1](http://stackoverflow.com/questions/28674432/how-to-update-widget-with-pjax-in-modal-window-in-yii2), [Thread 2](http://www.yiiframework.com/forum/index.php/topic/56040-pjaxreload-with-post-url/)) who have ever posted about this topic. Unfortunately, there is not a specific solution for this as far as I can see. How to refresh Listview inside modal without refreshing the whole page?\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/257289335","html_url":"https://github.com/yiisoft/yii2/issues/9040#issuecomment-257289335","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/9040","id":257289335,"user":{"login":"tunecino","id":5133397,"avatar_url":"https://avatars.githubusercontent.com/u/5133397?v=3","gravatar_id":"","url":"https://api.github.com/users/tunecino","html_url":"https://github.com/tunecino","followers_url":"https://api.github.com/users/tunecino/followers","following_url":"https://api.github.com/users/tunecino/following{/other_user}","gists_url":"https://api.github.com/users/tunecino/gists{/gist_id}","starred_url":"https://api.github.com/users/tunecino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tunecino/subscriptions","organizations_url":"https://api.github.com/users/tunecino/orgs","repos_url":"https://api.github.com/users/tunecino/repos","events_url":"https://api.github.com/users/tunecino/events{/privacy}","received_events_url":"https://api.github.com/users/tunecino/received_events","type":"User","site_admin":false},"created_at":"2016-10-31T13:09:44Z","updated_at":"2016-10-31T13:09:44Z","body":"ok that makes sense. thanks for explanations and welcome to Yii :+1: "}}
{"actor":{"display_login":"tunecino"}}