Skip to content

Commit

Permalink
Remove unnecessary isUJS example (#162)
Browse files Browse the repository at this point in the history
That kind of check is not needed since hotwired/turbo#1178
  • Loading branch information
Alberto Fernández-Capel committed Feb 9, 2024
1 parent 694d442 commit f05dfe4
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions _source/handbook/02_drive.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,11 @@ You can also disable the behaviour programatically by intercepting the `turbo:be

```javascript
document.addEventListener("turbo:before-prefetch", (event) => {
if (isUJS(event.target) || isSavingData() || hasSlowInternet()) {
if (isSavingData() || hasSlowInternet()) {
event.preventDefault()
}
})

function isUJS(link) {
return link.hasAttribute("data-remote") ||
link.hasAttribute("data-behavior") ||
link.hasAttribute("data-method") ||
link.hasAttribute("data-confirm")
}

function isSavingData() {
return navigator.connection?.saveData
}
Expand Down

0 comments on commit f05dfe4

Please sign in to comment.