I am using will_paginate in Rails. To leverage Turbo Frames I have put the entire pagination area into a Turbo Frame. So selecting page 3 changes the tag to:
<turbo-frame id="mainframe" src="http://localhost:3000/packages/vlc?page=3">
So far so good. The URL shown to the user does not change but I can freely switch between pages.
I also want to allow the users to edit data. Imagine that a form on the third page is submitted through turbo. The form looks like:
<turbo-frame id="screenshot_19519" src="http://localhost:3000/packages/vlc/screenshots/19519/edit"> <form action="/packages/vlc/screenshots/19519" accept-charset="UTF-8" method="post"> <input type="hidden" name="_method" value="patch"> <input type="text" name="screenshot[description]"> <button class="button success" type="submit"> </form> </turbo-frame>
The form submits the changes properly. However I am not sure how to properly redirect back to page 3. Do I need to add the page number as a hidden field in the form and use that to find out which page the user was on? I hope there is a nicer way to actually redirect back to where the user actually came from.
Thanks in advance for any hints.