-
Notifications
You must be signed in to change notification settings - Fork 433
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
Turbo can't be disabled for links with method: post/delete #288
Comments
The team added support for links and POST|PUT|PATCH|DELETE in v7.0.0-beta.6 see: https://github.com/hotwired/turbo/releases/tag/v7.0.0-beta.6 |
@efatsi did the new release fixed this for you? In my case, it does work, but it's still processing the delete as turbo_stream. Which caused my flash message to disappear (it redirects twice). |
I pulled down 7.0.0-beta.6 and it looks like the rails server is still processing the actions as TURBO_STREAM. |
For me works only forcing redirect to html format in sessions controller, like below:
|
I am also facing the same issue, I wish to turn off turbo for my omniauth buttons and currently they are not working.
I am on -
|
I have seen other threads pointing out that you should use However, as it has been pointed out they are semantically different. Moreover, with button_to you cannot use font-awesome icons on your button's text. Please let us know how can we workaround this, or if there is a fix coming soon. |
Using 7.0.0-beta.6: My sign-out link for devise is working with the
log:
|
@fabianzwodrei - I think this is an issue with Devise and XHR requests, and creates problems with Turbo since it uses XHR. Similar issue reported on Stack **Overflow. I believe this is because devise does not include see: ActionController::Redirecting
redirect_to posts_url, status: :see_other
redirect_to action: 'index', status: 303 I'm not sure any changes to turbo would solve this. I think your options are:
|
Thanks @tleish ! I tried the Your suggestion to change the devise configuration to use a |
Also running into this and was quite confused what was happening/why it was still sending as a TURBO_STREAM despite having disabled turbo both at my link level and higher up. Edit: 7.0.0-rc.3 for Turbo-rails package here |
@afomera - From what I have observed, ujs creates a brand-new form element when you click a link with |
I solved with @tleish solutions, it was the simplest way right now:
Thanks! |
This code works for me, though if I change it to a link_to or remove the data-turbo line it doesnt redirect. Just data-turbo = false or just button_to doesnt work either, it has to be both. And for whatever reason I can't figure out, it was somehow ending up at my show method for pages instead of redirecting to the page I specified. I dont understand why it just ignores redirects. Doesn't even get in to the desired controller action. |
Refer to the following issue: hotwired/turbo#288
It's work for me 100% |
I'd imagine a few people will get caught out with Rails 7 like myself, clear explanation in the docs here.
<div data-turbo="false">
<form>
<a href="/" data-turbo="true">Enabled if needed</a>
</form>
</div> |
Same goes for all other non get requests (i.e. |
Cool to see some helpful advice, but in my case it doesn't seem too easy to avoid link_to for my button. I'm using a tailwindcss styled link_to button with an SVG inside. When I change link_to to button_to I get something that doesn't work: <input type="submit" value="<svg..."... Also setting I would like to be able to use turbo/hotwire for live deleting elements from pages like index, but when deleting an object using a button on the show page I would like to do a redirect, because the show page is obsolete after deleting the object. |
OMG I was thinking too complicated. If you want to change the request type you just have to add # instead of:
link_to "Delete", object, method: :delete
# do
link_to "Delete", polymorphic_path(object, format: :html), method: :delete |
Just adding this comment here since it could help others migrating to Turbo and keeping UJS working together. The We found a really good alternative to keep the existing behavior of UJS without having to change anything else: Turbo.setFormMode("optin"); By doing this all forms will need to add NOTE: I've tried using |
Have we considered duplicating the data-turbo attributes from the link to the form? Something similar to this in rails-ujs.js
|
I've seen a few issues hovering around this issue (hotwired/turbo-rails#31, #45, #74). But it seems that disabling turbo is not respected for links with non-GET methods.
I'm attempting to do the following:
and the request is always processed as
TURBO_STREAM
:If I use
button_to
instead oflink_to
, the disabling of turbo works properly.Versions:
The text was updated successfully, but these errors were encountered: