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 DOMContentLoaded event alternative for Turbo #995

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

sergioalcaraz
Copy link
Contributor

In this pull request, the turbo:load event is added together with the already existing DOMContentLoaded event to avoid having to reload the page on each navigation.


// Add support for turbo DOMContentLoaded alternative
// see https://turbo.hotwired.dev/reference/events#turbo%3Aload
doc.addEventListener('turbo:load', onReady, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will close the toolbar and attach duplicate message handlers. I don't think that's what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a condition to set which of the two events to be used

Turbo ? 'turbo:load' : 'DOMContentLoaded';

@markstory markstory merged commit 253ae96 into cakephp:5.x Apr 3, 2024
3 of 6 checks passed
@markstory
Copy link
Member

Thank you 🎉

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 this pull request may close these issues.

2 participants