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

hotwired/turbo compatibility #121

Open
glaszig opened this issue Apr 26, 2024 · 0 comments · May be fixed by #122
Open

hotwired/turbo compatibility #121

glaszig opened this issue Apr 26, 2024 · 0 comments · May be fixed by #122

Comments

@glaszig
Copy link

glaszig commented Apr 26, 2024

peek listens for page:change and turbolinks:load to trigger the necessary peek:update event. this works with turbolinks but not with turbo drive. the following workaround will make peek work with hotwired/turbo:

// app/assets/javascripts/application.js
//= require peek

const peekEnabled = () => document.querySelectorAll('#peek').length
document.addEventListener("turbo:load", e => {
  if (peekEnabled()) {
    const event = new CustomEvent("peek:update")
    document.dispatchEvent(event)
  }
})
@glaszig glaszig linked a pull request Apr 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant