-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using data-turbo-action "replace" or "advance" cause turbo:before-cache event to be called on live page #1259
Comments
I second this, the documentation encourages us to prepare pages to be cached, and this often means disposing of third party libraries and such, and then reinstating them. We frequently use The easiest "way" to fix it for now is to disable cache on the page, which is definitely not optimal, as we also use cache for smoother navigation and restoration of various state (a slide the user was at, or a timestamp on a video...). I really think the dispatching of this event is a mistake, because it's dispatched after every other event, even after |
This problem is still relevant. I spent several hours today, trying to find a way to make it work but just ended up giving up and disabling the cache entirely too. My Problem is that you cannot use select2 with turbo frames, because the select2 fields duplicate when you use browser navigation... It looks like that: |
I’m running into the same issue. I was already using the Disabling the cache on the page was not an option. I came up with a messy workaround (emphasis on messy): I added a state variable in my teardown method, setting it to false on |
This problem also affects turbo:before-visit event |
The Docs (https://turbo.hotwired.dev/handbook/building#preparing-the-page-to-be-cached) suggest we listen to the before-cache event to tear down controllers and prepare for a page cache. But having a turbo frame loaded with data-turbo-action="advance" or "replace" somehow dispatches a before-render event on the newly loaded live page, which in my case breaks a couple of controllers.
I'm pretty sure this event has no reason to be dispatched on a live page, it should only be dispatched when exiting a page.
I'll try to reverse-engineer the turbo source code and if I find the culprit i'll open a PR, but so far no luck.
This wrongfully called page cache is the root cause of some other issues as well:
#1075
#919
#1008
The text was updated successfully, but these errors were encountered: