Following the Programming Phoenix 1.4 beta book, I’d like to use a simple jQuery selector in my
form.html.eex template. I have a few questions as to what is the best approach for this:
In which folder is it best to save the js file. If I have a Context/Model, e.g.
Multimedia/Video- and a
Video, where should I save the js code needed for this page? I prefer to save the js code near to the page on which it will be used, so I would have it in a folder such as
templates/video/jsbut it seems that I have to put them in
assets/jsfor webpack to know where to look. Is it common practice out there to do this?
In anycase, my templates cannot find the jquery
$even though in my
app.jsI have this imported. I have put a simple
<script>tag in the
form.html.eextemplate which will use the
$jQuery selector, and I get an error saying
$ is not defined- why is this? I thought $ was global when copied to