{"action":"created","issue":{"url":"https://api.github.com/repos/rails/turbolinks/issues/291","labels_url":"https://api.github.com/repos/rails/turbolinks/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/rails/turbolinks/issues/291/comments","events_url":"https://api.github.com/repos/rails/turbolinks/issues/291/events","html_url":"https://github.com/rails/turbolinks/pull/291","id":21386902,"number":291,"title":"Add possibility to keep current scroll position in the Turbolinks.visit API","user":{"login":"tzvetkoff","id":710719,"avatar_url":"https://avatars.githubusercontent.com/u/710719?v=3","gravatar_id":"","url":"https://api.github.com/users/tzvetkoff","html_url":"https://github.com/tzvetkoff","followers_url":"https://api.github.com/users/tzvetkoff/followers","following_url":"https://api.github.com/users/tzvetkoff/following{/other_user}","gists_url":"https://api.github.com/users/tzvetkoff/gists{/gist_id}","starred_url":"https://api.github.com/users/tzvetkoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzvetkoff/subscriptions","organizations_url":"https://api.github.com/users/tzvetkoff/orgs","repos_url":"https://api.github.com/users/tzvetkoff/repos","events_url":"https://api.github.com/users/tzvetkoff/events{/privacy}","received_events_url":"https://api.github.com/users/tzvetkoff/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2013-10-22T14:46:35Z","updated_at":"2015-05-26T03:00:55Z","closed_at":"2015-05-26T03:00:55Z","pull_request":{"url":"https://api.github.com/repos/rails/turbolinks/pulls/291","html_url":"https://github.com/rails/turbolinks/pull/291","diff_url":"https://github.com/rails/turbolinks/pull/291.diff","patch_url":"https://github.com/rails/turbolinks/pull/291.patch"},"body":"On certain occasions some might need to keep current scroll position.\r\nIn my case I call `Turbolinks.visit(location.href)` to reload the content of the current page -- this is an improvised replacement for `location.reload()`.\r\nProblem is, that if you want to reload the current page content for, say, new elements created by AJAX form submission, the page will scroll back to top, yet you want to keep the scroll position.\r\n\r\nPartial replacements is a way to do this, but requires specific Rails code on the backend to just render that partial and then you're getting even more tied to the front-end.\r\n\r\nSo, I've added an extra option to keep the scroll position.\r\n\r\nWhen invoking Turbolinks manually:\r\n```javascript\r\nTurbolinks.visit(path, { keepScrollPosition: true });\r\n```\r\n\r\nOr by marking the element with the `data-turbolinks-keep-scroll` attribute:\r\n```html\r\n<a href=\"/path\" data-turbolinks-keep-scroll>Change the page and keep current scroll position.</a>\r\n```\r\n\r\nEdited: **2015-05-04**\r\n"},"comment":{"url":"https://api.github.com/repos/rails/turbolinks/issues/comments/105371848","html_url":"https://github.com/rails/turbolinks/pull/291#issuecomment-105371848","issue_url":"https://api.github.com/repos/rails/turbolinks/issues/291","id":105371848,"user":{"login":"Thibaut","id":17579,"avatar_url":"https://avatars.githubusercontent.com/u/17579?v=3","gravatar_id":"","url":"https://api.github.com/users/Thibaut","html_url":"https://github.com/Thibaut","followers_url":"https://api.github.com/users/Thibaut/followers","following_url":"https://api.github.com/users/Thibaut/following{/other_user}","gists_url":"https://api.github.com/users/Thibaut/gists{/gist_id}","starred_url":"https://api.github.com/users/Thibaut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Thibaut/subscriptions","organizations_url":"https://api.github.com/users/Thibaut/orgs","repos_url":"https://api.github.com/users/Thibaut/repos","events_url":"https://api.github.com/users/Thibaut/events{/privacy}","received_events_url":"https://api.github.com/users/Thibaut/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T03:00:55Z","updated_at":"2015-05-26T03:00:55Z","body":"`Turbolinks.visit(url, scroll: false)` has been merged into master (#528). I will PR `data-turbolinks-scroll=false` and update the docs this week-end.\r\n\r\nThanks all for pushing this forward."}}