Skip to content

Commit

Permalink
Document data-turbo-stream attribute
Browse files Browse the repository at this point in the history
Documents the `data-turbo-stream` attribute introduced in
hotwired/turbo#612.
  • Loading branch information
kevinmcconnell committed Jul 18, 2022
1 parent d429944 commit bb08da7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _source/handbook/04_streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def destroy
end
```

By default, Turbo doesn't add the `text/vnd.turbo-stream.html` MIME type when submitting links, or forms with a method type of `GET`. To use Turbo Streams responses with `GET` requests in an application you can instruct Turbo to include the MIME type by adding a `data-turbo-stream` attribute to a link or form.

[MIME type]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
[method]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-method
[Accept]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
Expand Down
1 change: 1 addition & 0 deletions _source/reference/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following data attributes can be applied to elements to customize Turbo's be
* `data-turbo-cache="false"` removes the element before the document is cached, preventing it from reappearing on restoration Visits.
* `data-turbo-eval="false"` prevents inline `script` elements from being re-evaluated on Visits.
* `data-turbo-method` changes the link request type from the default `GET`. Ideally, non-`GET` requests should be triggered with forms, but `data-turbo-method` might be useful where a form is not possible.
* `data-turbo-stream` specifies that a link or form can accept a Turbo Streams response. Turbo [automatically requests stream responses](/handbook/streams#streaming-from-http-responses) for form submissions with non-`GET` methods; `data-turbo-stream` allows Turbo Streams to be used with `GET` requests as well.
* `data-turbo-confirm` presents a confirm dialog with the given value. Can be used on `form` elements or links with `data-turbo-method`.

## Automatically Added Attributes
Expand Down

0 comments on commit bb08da7

Please sign in to comment.