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

bugfix(phoenix_html.js): Make IIFE idempotent by injecting a global _… #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomciopp
Copy link

…phx_loaded boolean flag that is set after setup. Prevents event handlers from being set multiple times in case of libraries like turbolinks which would run this code several times.

@josevalim @chrismccord fixes #284.

After taking some time to think about the problem, I took a different approach than what I outlined in the previous discussion. I think this is a simpler and more robust solution to the problem since there is not much javascript actually being executed. Let me know what you think.

…phx_loaded boolean flag that is set after setup. Prevents event handlers from being set multiple times in case of libraries like turbolinks which would run this code several times
@josevalim
Copy link
Member

Thanks for the PR!

I am not sure but wouldn’t it be more idiomatic to use a named function? It feels like adding this to work around a limitation on Turbolinks, which is arguably the one in the wrong here, is not very clean.

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.

Javascript data-confirm fires multiple times
2 participants