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

Update event listener setup #262

Merged
merged 2 commits into from
Aug 18, 2021
Merged

Update event listener setup #262

merged 2 commits into from
Aug 18, 2021

Conversation

tenpaiyomi
Copy link
Contributor

@tenpaiyomi tenpaiyomi commented Aug 18, 2021

Modifies the non-xhr event listener to ensure that it will only run a single time (initial page load) and not on subsequent page loads unless the event listener is set up again. This resolves issues where a user would navigate to a page that had high charts in place, and then navigate to another page and get inundated with console errors because the event was attempting to run setup on the charts again with containers that did not exist (or, erroneously get charts set up in containers that should not have them on the new page).

Likewise, it ensures that subsequent page visits to the page that set up the event listener does not set up multiple repetitive event listener events that perform the same action, as the previous set up would add on another duplicate but different event listener to the document (or window in the case of non-xhr and non-Turbo(links)) element every single time the page was loaded without ever removing any of the old listeners.

Resolves an issue introduced in PR #258

Resolves #255
Resolves #223

Supersedes PR #249
Supersedes PR #224

…, instead of on every single turbo:load event, thus causing errors on subsequent navigation events.
…y the event listener on execution instead of allowing the event functions to accumulate over multiple page visits.
@tenpaiyomi tenpaiyomi changed the title Update turbo:load event listener Update event listener setup Aug 18, 2021
@michelson
Copy link
Owner

michelson commented Aug 18, 2021

Thanks! very valuable feature

@michelson michelson merged commit fd5c4f7 into michelson:master Aug 18, 2021
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.

Turbolinks >= 5 accumulates event listeners Problem with Turbolinks 5 (Highcharts: Error #13)
2 participants