-
Hello: My problem is related to defining JavaScript timeouts. I have set up a simple timeout to refresh the same page every 5 seconds, but I've noticed something peculiar. When I navigate away to a different page, it seems like the timeout is not being reset, and instead, it proceeds to refresh the previous page I was on. This is not the desired behavior. My primary question is, is it possible to disable Turbo in Orchid? If so, how can I go about it? If not, is there a known workaround to this issue? Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @jfuentesa. Hotwired is like an emulation of SPA which saves state (like React/Vue/Angular). By that, if you have some global thing, you need to keep an eye on that state. The package relies more and more on the framework, so disabling it could have consequences. To deactivate it, you have to call it: window.Turbo.session.drive = false I don't recommend doing that. Maybe if you tell me the problem you want to solve by refreshing the page every 5 seconds, I can help you more effectively. |
Beta Was this translation helpful? Give feedback.
-
to address your JavaScript timeout problem, when you navigate away from a page, the timeout you set may still be active and will continue to execute unless explicitly cleared or cancelled. To avoid this behavior, you can use the clearTimeout() function to cancel the timeout when navigating away from the page. |
Beta Was this translation helpful? Give feedback.
This is roughly what your JS controller will look like
But you can not update full page and make even better (More difficult for a beginner), such as update only part of the page: