Use turbolinks:before-cache event instead of turbolinks:visit
See original GitHub issueHi!
Have you tried this already? If there’s no known issues, I think before-cache
is better because components would be alive and not removed from current page until new page is loaded.
Using turbolinks:visit
with slow internet connection, components disappear from page before new page is loaded.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Turbolinks makes navigating your web application faster
Listen for the turbolinks:before-cache event if you need to prepare the document before Turbolinks caches it. You can use this event to reset...
Read more >Turbolinks Cheatsheet - Key Shift in Cmd
Copies the page to cache using cloneNode(true), so when it's returned from the cache, attached event listeners and associated data are discarded ...
Read more >How We Migrated To Turbolinks Without Breaking Javascript
Turbolinks caches pages immediately before navigating away from them. When the user clicks the "Back" button, Turbolinks fetches the previous ...
Read more >Javascript DOM events before and after Turbolinks cache
I think the problem here is that you are binding to two events: turbolinks:load and $(document).ready() . Turbolinks does not discard event ......
Read more >Turbolinks for faster web navigation - LogRocket Blog
Turbolinks stores every page you visit within an internal cache, so that when you need to access the same page, Turbolinks can retrieve...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So I had this problem and it was caused by the same thing as @nicklozon, where I had template code inside my
.html.erb
file.And then in
library.js
, which I imported into myapplication.js
:^^^ the above is what it looks like when the problem exists. ^^^
@printercu’s script (this) worked for me, though it does seem like - based on nick’s comment previously - you can also avoid this problem by simply not including the Vue.js custom elements in the
.html.erb
files, e.g. by plugging it into adata-
attribute and then mounting it on that, or something?@nicklozon can you please give a try for https://gist.github.com/printercu/e202851c370ffc38bcdedeb8300d417e It should work fine both for
.vue
files and<script type='x-template'>
. I don’t usediv
templates because they have some limitations/edgecases and can show template source on page while page load, so have not tested for them.Compiled coffee => js