Need to prevent re-performing some JavaScript page setup actions when they've already been performed #943
Labels
area: ui
Anything to do with the user interface, particularly UX concerns
status: needs investigation
This needs more investigation.
status: planned
We like the idea and might get around to it at some point.
type: bug
Buggy or otherwise incorrect behaviour.
The underlying issue is that the
$(document).on('turbolinks:load', );
event can fire more than once on pages where it's previously fired. This mostly happens when using the browser's forward and back capability.On metasmoke, we typically use the utility function
onLoad()
to add functions to be run on that event. There are a considerable number of places throughout the JavaScript where it's assumed that the operations which are being performed within theonLoad()
callback are operating on HTML on which they have never been performed. When these are run a second time on the same DOM/HTML, it can result in a variety of unintended consequences, including multiple manipulations and adding multiple event listeners (when the event listener being added is not the same function Object; e.g. when it's anonymous) which are performing the same action.There are, of course, also things which do need to be run again when the same DOM/HTML is presented to the user. As a result, it's not a case where we just need to prevent everything added through
onLoad
from being re-executed on the same DOM/HTML.The text was updated successfully, but these errors were encountered: