2

where would I add jQuery script tags for templates? I get an error if I add them to the template.js page. For example, where would i go about adding a mouseover function?

Thanks!

Trung Tran
  • 13,141
  • 42
  • 113
  • 200
  • possible duplicate of [How can I add third-party JavaScript libraries to a Meteor application?](http://stackoverflow.com/questions/11009971/how-can-i-add-third-party-javascript-libraries-to-a-meteor-application) – Kyll Aug 05 '15 at 18:10

2 Answers2

2

To add client-side, place it in project_name/public

To add plugin, run

Meteor add jquery

For further information checkout this answer

Community
  • 1
  • 1
Medet Tleukabiluly
  • 11,662
  • 3
  • 34
  • 69
  • When you see such a closely related question, the best thing is to flag as duplicate if your answer does not have much to add to the issue. – Kyll Aug 05 '15 at 18:10
  • In the duplication, they talk about third party libraries, not jquery(indeed jquery is available internally) and dup answer says that jquery is available by default, so considered this is not that much duplication, I would agree with you if the question was about jquery-ui or something else – Medet Tleukabiluly Aug 05 '15 at 18:16
2

The 'meteor' place to attach events is in Template.myTemplate.events (docs) but you can also run arbitrary jQuery in Template.myTemplate.onRendered = function(){ //code here}. (docs) These can go in the template's js file.

If you haven't removed jQuery, you don't need to add it, it's there by default.

Generally you don't need to add script tags anywhere.

Jordan Davis
  • 1,271
  • 14
  • 24