RagtagOpen / nomad

Apache License 2.0
10 stars 22 forks source link

ReferenceError: Can't find variable: $ #741

Closed dryan closed 5 years ago

dryan commented 6 years ago

https://sentry.ragtag.org/ragtag/nomad-prod/issues/179/

find.js is being loaded before jQuery which is causing the $ variable to be undefined. We need to fix the loading order. Also why are we loading jQuery twice?

ReferenceError: Can't find variable: $
  at initMap (/carpools/find:190:4)
  at None (/maps/api/js:124:274)
  at None (/maps/api/js:124:113)
  at promiseReactionJob ([native code])
seans887 commented 6 years ago

@dryan I can't seem to reproduce the "can't find variable" issue (either locally or on https://ny-nomad.ragtag.org/carpools/find), but definitely seeing jQuery being loaded multiple times. I have a feeling that might be a part of whatever Bootstrap package we're using loading it on its own?

iandees commented 6 years ago

Yep: https://pythonhosted.org/Flask-Bootstrap/faq.html#why-are-you-shipping-jquery-1-instead-of-jquery-2

dryan commented 6 years ago

I haven't either but I'm guessing that's a matter of us having it cached. We've had multiple reports of it in Sentry. Getting the order of <script> tags should take care of it. Can we try putting jQuery 3 first, removing the jQuery 1 tag altogether then putting in the external dependencies then find.js and script.js?

dryan commented 6 years ago

If it's being loaded by Bootstrap, let's see if we can remove the call to jQuery 3 then. But we still need to get find.js's tag in the HTML after jQuery's tag.

iandees commented 6 years ago

Remove this line:

https://github.com/RagtagOpen/nomad/blob/master/app/templates/_template.html#L9

or

Don't call {{ super() }} there at all and include the fetch of bootstrap.js from the template we're inheriting from in our own template.