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

data-turbo-action is being ignored in link_to #359

Open
ondrej-zadnik opened this issue Jul 13, 2022 · 1 comment
Open

data-turbo-action is being ignored in link_to #359

ondrej-zadnik opened this issue Jul 13, 2022 · 1 comment

Comments

@ondrej-zadnik
Copy link

Hello,

We are trying to migrate from Turbolinks to Turbo and we also use turbo ios app.

with turbolinks we used this:

view:
link_to add_to_favorites_path(id: id), method: :post, remote: true, class: 'button', data: { disable_with: _("Adding...")} do ...

controller:
redirect_back favorites_path, notice: "added to favorites", turbolinks: :replace

after rewriting to turbo:

view:
link_to add_to_favorites_path(id: id), class: 'button', data: { turbo_method: :post, disable_with: _("Adding..."), turbo_action: "replace" } do ...

controller:
redirect_to favorites_path, notice: "added to favorites", status: :see_other

In the browser everything works correctly but in turbo native mobile app :replace action is ignored and fallback to advance. I tried to search in the code for link_to with non-get method and I didn't find where the turbo-action method being set.


Screenshot 2022-07-12 at 0 11 04


After rewrite to button_to everything works correctly:
button_to add_to_favorites(id: id), class: 'button', data: { disable_with: "Adding..."), turbo_action: "replace" } do ...

Another link_to with data-turbo-method: :delete behaves the same way

Is my guess correct and link_to with data-turbo-method ignores data-turbo-action?

@dhh
Copy link
Member

dhh commented Jul 15, 2022

That sounds right. Please do investigate adding support for data-turbo-action to link_to 👍

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

2 participants