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

Unable to Enable and Disable Turbo Drive Between Pages #1369

Open
albertski opened this issue Feb 13, 2025 · 0 comments
Open

Unable to Enable and Disable Turbo Drive Between Pages #1369

albertski opened this issue Feb 13, 2025 · 0 comments

Comments

@albertski
Copy link

albertski commented Feb 13, 2025

I am attempting to enable Turbo Drive iteratively in my Rails app to test it on specific pages before enabling it across the entire application.

I add the following to any controller I want to enable Turbo:

before_action :enable_turbo

def enable_turbo
  @turbo_enabled = true
end

Add the following to layout:

%html{data: { turbo: @turbo_enabled ? 'true' : 'false' } }

This works for the most part. However, I’ve encountered an issue:

If I navigate from a page with Turbo enabled to a page where Turbo is disabled, the page is still loaded with Turbo Drive. This breaks functionality on some page pages where I’m not ready to enable Turbo.

Workaround
Add data: { turbo: false } to all my links that lead to pages where Turbo should be disabled.

Is there a better approach to dynamically enable and disable Turbo Drive between pages without needing to modify all the links manually?

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

1 participant