turbolinks / turbolinks-classic

Classic version of Turbolinks. Now deprecated in favor of Turbolinks 5.
MIT License
3.54k stars 428 forks source link

redirect_to and scroll to acnhor #589

Closed vizo closed 8 years ago

vizo commented 9 years ago

When using redirect_to with anchor, change and scroll:true, it doesn't scroll to anchor.

I checked source code and i see that scroll param is never passed from server to client side. I fixed this also in pull request https://github.com/rails/turbolinks/pull/588.

Thibaut commented 8 years ago

Could you provide a test app for reproducing this? I don't think the solution is to expose the scroll option server-side.

vizo commented 8 years ago

Use case is when you update some resource "inline" (single page). For example you have list of items with edit button which calls turbolinks.visit to edit inline (to show form for this item on list) and after save you do redirect_to with anchor to scroll back to saved item on list. But without scroll true it doesn't scroll to anchor (to saved item on list).

I can send you private message with link to my private app where i use this.

I think if change param is exposed to server side, i don't see problem to expose scroll as well ;)

Thibaut commented 8 years ago

The fix isn't to expose scroll server-side. We should make Turbolinks.visit with change scroll to the URL fragment by default, instead of leaving the scroll position unchanged.

I will take care of this in the coming weeks.

vizo commented 8 years ago

Yes i agree, this solution is better. Thanks :)