1
votes

I tried to use npm to add jquery into a Phoenix project, but somehow fsevents just can't run under Win OS. So I just download jquery and put it under /web/static/vendor folder.

I try to understand what necessary to be done by reading this article, but I just couldn't get it...

How can I access this jquery from my template page? A step by step tutorial would be great, because I really not familiar with node.js or brunch.

Thanks :)

1
Managing npm packages is, for me, the most channeling part of developing Phoenix apps. I submitted an issue against phoenix a couple days ago. No one has commented on it. - Steve Pallen
I came from java background, and really really not familiar with npm... in spring framework, adding js lib is just as simply as dump it in a folder and accessing it directly from jsp... I don't wanna get bother with npm problem with Win OS. If I can access additional js directly from template page would be good enough... so I can move on :) - Bromo Programmer

1 Answers

2
votes

I assume you're using brunch.js by default, and your jquery file is being concatenated into app.js (you can change the order of the concatenation of files, check your brunch-config.js) From now you would be able to access jquery global variable in your /web/static/js/app.js etc, also make sure if you need an inline script in your template, to place it after <script src="<%= static_path(@conn, "js/app.js") %> </script>