I have a template which holds a form with a few elements. I need to initialize the JS for some of these elements using jquery, but I keep getting an error saying: “$ is not defined”. I followed all the steps in this post: Setup, import and use Javascript in Phoenix and also from the official Phoenix docs.
And you’re including app.js in your layout/page right? If so have you tried moving the script around on the page to be at the beginning/end of the body tag?
Remember that things compiled into modules are not available at global scope nor should they be. Instead of doing things like $... you should be doing things like require("jQuery")... (if using brunch) or so (which you can bind to a variable if you want).