Bromo Programmer
Bromo Programmer

Reputation: 670

Using JQuery in Phoenix

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 :)

Upvotes: 1

Views: 1182

Answers (1)

sysashi
sysashi

Reputation: 311

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>

Upvotes: 2

Related Questions