Skip to content

Commit

Permalink
Merge pull request hotwired#122 from ghiculescu/data-turbo-confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh authored Dec 24, 2022
2 parents b88587e + ac0b51a commit 67bc88f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions _source/handbook/02_drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ The link will get converted into a hidden form next to the `a` element in the DO

You should also consider that for accessibility reasons, it's better to use actual forms and buttons for anything that's not a GET.

## Requiring Confirmation for a Visit

Decorate links with `data-turbo-confirm`, and confirmation will be required for a visit to proceed.

```html
<a href="/articles" data-turbo-confirm="Do you want to leave this page?">Back to articles</a>
<a href="/articles/54" data-turbo-method="delete" data-turbo-confirm="Are you sure you want to delete the article?">Delete the article</a>
```

Use `Turbo.setConfirmMethod` to change the method that gets called for confirmation. The default is the browser's built in `confirm`.


## Disabling Turbo Drive on Specific Links or Forms

Expand Down
8 changes: 8 additions & 0 deletions _source/reference/drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Sets the delay after which the [progress bar](/handbook/drive#displaying-progres

Note that this method has no effect when used with the iOS or Android adapters.

## Turbo.setProgressBarDelay

```js
Turbo.setConfirmMethod(confirmMethod)
```

Sets the method that is called by links decorated with [`data-turbo-confirm`](/handbook/drive#requiring-confirmation-for-a-visit). The default is the browser's built in `confirm`. The method should return `true` if the visit can proceed.

## Turbo.session.drive

```js
Expand Down

0 comments on commit 67bc88f

Please sign in to comment.