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

Turn links with methods into form submissions #277

Merged
merged 1 commit into from
Jun 8, 2021

Conversation

dhh
Copy link
Member

@dhh dhh commented Jun 4, 2021

Rails UJS offered a path to turn links into form submissions via the data-method attribute. This PR recreates that capability under data-turbo-method (but also with data-method for compatibility with existing apps built to Rails UJS).

The link is turned into a form that's added next to the link in the dom, such that all the frame scopes still apply, and corresponding behavior is triggered.

For accessibility reasons, we should continue to promote buttons rather than method links, but this makes Hotwire much easier to fit into existing applications that were built to Rails UJS standards.

@dhh dhh merged commit 880ea1b into main Jun 8, 2021
@dhh dhh deleted the link-with-methods-turn-into-form-submissions branch June 8, 2021 08:59
@Intrepidd
Copy link
Contributor

This seems to only work within a turbo-frame, is it expected behaviour ? I am not sure as it is advertised to be a replacement for data-method links

@dhh
Copy link
Member Author

dhh commented Jul 1, 2021

@Intrepidd Ah yes, need to expand it to all cases. If you want to take a swing at a PR for that 👍

@Intrepidd
Copy link
Contributor

@dhh I took a swing at it in #299 , I need a little bit of guidance though before wrapping it up

ghiculescu added a commit to ghiculescu/turbo-site that referenced this pull request Oct 11, 2021
seanpdoyle added a commit to seanpdoyle/turbo-rails that referenced this pull request Oct 12, 2021
As an alternative to building support for Rails' Unobtrusive JavaScript
into `@hotwired/turbo` itself, instead publish a
`@hotwired/turbo-rails/ujs` file to re-use the existing `@rails/ujs`
hooks, and bridge the gaps between new `turbo:`-prefixed and
`ajax:`-prefixed events.

This is a re-imagining of [hotwired/turbo#40][] and
([hotwired/turbo#384][]). If deemed viable, this work would yield some
follow up tasks:

* drop support for `[data-turbo-method]` ([hotwired/turbo#277][])
* drop support for `[data-confirm]` ([hotwired/turbo#379][])

[hotwired/turbo#40]: hotwired/turbo#40
[hotwired/turbo#277]: hotwired/turbo#277
[hotwired/turbo#379]: hotwired/turbo#379
[hotwired/turbo#384]:hotwired/turbo#384
seanpdoyle added a commit to seanpdoyle/turbo-rails that referenced this pull request Oct 12, 2021
As an alternative to building support for Rails' Unobtrusive JavaScript
into `@hotwired/turbo` itself, instead publish a
`@hotwired/turbo-rails/ujs` file to re-use the existing `@rails/ujs`
hooks, and bridge the gaps between new `turbo:`-prefixed and
`ajax:`-prefixed events.

This is a re-imagining of [hotwired/turbo#40][] and
([hotwired/turbo#384][]). If deemed viable, this work would yield some
follow up tasks:

* drop support for `[data-turbo-method]` ([hotwired/turbo#277][])
* drop support for `[data-confirm]` ([hotwired/turbo#379][])

[hotwired/turbo#40]: hotwired/turbo#40
[hotwired/turbo#277]: hotwired/turbo#277
[hotwired/turbo#379]: hotwired/turbo#379
[hotwired/turbo#384]:hotwired/turbo#384
seanpdoyle added a commit to seanpdoyle/turbo-rails that referenced this pull request Oct 12, 2021
As an alternative to building support for Rails' Unobtrusive JavaScript
into `@hotwired/turbo` itself, instead publish a
`@hotwired/turbo-rails/ujs` file to re-use the existing `@rails/ujs`
hooks, and bridge the gaps between new `turbo:`-prefixed and
`ajax:`-prefixed events.

This is a re-imagining of [hotwired/turbo#40][] and
([hotwired/turbo#384][]). If deemed viable, this work would yield some
follow up tasks:

* drop support for `[data-turbo-method]` ([hotwired/turbo#277][])
* drop support for `[data-confirm]` ([hotwired/turbo#379][])

[hotwired/turbo#40]: hotwired/turbo#40
[hotwired/turbo#277]: hotwired/turbo#277
[hotwired/turbo#379]: hotwired/turbo#379
[hotwired/turbo#384]:hotwired/turbo#384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants