You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With all the javascript errors I'm encountering in #3688 and the various jQuery related errors we've seen in the past, I'm now realizing that we need better encapsulation in these files.
What all these errors boil down to is this: jQuery in application.js is required in other js files, so we set it as a global variable attached to the window. This is super fragile and indeed seems to work by coincidence. Its fragile specifically because we end up making additions to this global variable and that can cause a lot of wonkiness especially if the actual javascript file that's been built has different jQuery definitions (i.e., datatables is attached to one of the imports, but not the other).
This ticket is to fix up our asset pipeline and use of javascript files so that we don't have to fix mysterious jQuery errors every 6 months. I think half of it is reducing our dependency on jQuery (preferring plain ol javascript if we can) and correcting our imports & exports so that the resulting javascript files will always work.
With all the javascript errors I'm encountering in #3688 and the various jQuery related errors we've seen in the past, I'm now realizing that we need better encapsulation in these files.
What all these errors boil down to is this: jQuery in
application.js
is required in other js files, so we set it as a global variable attached to the window. This is super fragile and indeed seems to work by coincidence. Its fragile specifically because we end up making additions to this global variable and that can cause a lot of wonkiness especially if the actual javascript file that's been built has different jQuery definitions (i.e., datatables is attached to one of the imports, but not the other).This ticket is to fix up our asset pipeline and use of javascript files so that we don't have to fix mysterious jQuery errors every 6 months. I think half of it is reducing our dependency on jQuery (preferring plain ol javascript if we can) and correcting our imports & exports so that the resulting javascript files will always work.
The text was updated successfully, but these errors were encountered: