Skip to content

Instantly share code, notes, and snippets.

@dacook
Created April 17, 2024 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacook/b34f8148efbd2a771d0addb0addaad26 to your computer and use it in GitHub Desktop.
Save dacook/b34f8148efbd2a771d0addb0addaad26 to your computer and use it in GitHub Desktop.
Hotwire Turbo events debug messages
// I couldn't easily install gem [hotwire-debug](https://github.com/beflagrant/hotwire-debug),
// so just copy/pasted the bare minimum source into my project.
// Then I updated the events list to include all events in the documentation: https://turbo.hotwired.dev/reference/events
// (hmmm, probably could have just added a general event listener and filtered by name ~= /turbo:/
console.log('init hotwire-debug');
var turboEvents = [
"turbo:before-cache",
"turbo:before-render",
"turbo:before-visit",
"turbo:visit",
"turbo:click",
"turbo:load",
"turbo:render",
"turbo:submit-end",
"turbo:submit-start",
"turbo:morph",
"turbo:before-morph-element",
"turbo:morph-element",
"turbo:before-morph-attribute",
"turbo:before-frame-render",
"turbo:frame-render",
"turbo:frame-load",
"turbo:frame-missing",
"turbo:before-stream-render",
"turbo:before-fetch-request",
"turbo:before-fetch-response",
"turbo:before-prefetch",
"turbo:fetch-request-error",
]
turboEvents.forEach(function(turboEvent) {
document.addEventListener(turboEvent, function() {
// if (showChanges()) {
console.log("⚡️ " + turboEvent);
// handleChange();
// }
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment