Skip to content
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

Replacement for data-turbolinks-permanent? #21

Closed
danjac opened this issue Dec 23, 2020 · 5 comments
Closed

Replacement for data-turbolinks-permanent? #21

danjac opened this issue Dec 23, 2020 · 5 comments

Comments

@danjac
Copy link

danjac commented Dec 23, 2020

What is the best practice for upgrading from Turbolinks 5 regarding the turbolinks-permanent directive? In this particular case, I use this to keep a video or audio component running between page transitions, without having the media element restart. The new turbo-frame does not seem to do the same thing. Has this been removed from the new Turbo? What's the best practice here?

@cj
Copy link

cj commented Dec 23, 2020

@danjac Turbo has data-turbo-permanent https://turbo.hotwire.dev/handbook/building#persisting-elements-across-page-loads

@danjac
Copy link
Author

danjac commented Dec 23, 2020

One thing I've noticed with data-turbo-permanent vs data-turbolinks-permanent: while the HTML itself is preserved, there appears to be an issue with elements inside the data-turbo-permanent element (at least in Chromium browsers). Page transitions seem to cause a reset, reloading the element, so if for example the audio is playing it will restart. This was not an issue in Turbolinks 5.

@danjac
Copy link
Author

danjac commented Dec 23, 2020

Re audio: this appears to be similar to older Turbolinks issue here. Looks like workaround is to create the Audio element in Javascript rather than in the HTML (i.e. const audio = new Audio(...)) inside e.g. your Stimulus controller:

turbolinks/turbolinks#157

@sstephenson
Copy link
Contributor

data-turbo-permanent has not been removed, it just doesn't (currently) work for frame or stream renders.

@danjac
Copy link
Author

danjac commented Dec 23, 2020

Is there an open issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants