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

Add section about changed behavior for links and forms #179

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions _source/reference/drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ description: "A reference of everything you can do with Turbo Drive."

# Drive

## Changed link and form behavior
Turbo Drive intercepts the following:

* `"click"` event on link elements
* `"submit"` event on form elements

Then does the following:
1. Prevents the default behavior
2. Updates the browser's URL, using the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)
3. Makes an AJAX request to the appropriate URL
4. Replaces the browser's `<body>` element with the response's `<body>` element, and merges the contents of their `<head>` elements if they changed
5. If the URL includes `#hash` location, attempts to scroll to the element with that `id`

## Turbo.visit

```js
Expand Down