1

I added the JQuery list package to meteor and it recognizes it. But when I write JQuery code inline in <script></script> tags in the apps main html file it does not recognize it ( but I don't get an error). When I write JQuery code in my meteor app .js file I get an error. So I am confused as to how one is suppose to write with javascript or added library packages (like JQuery) once they are added. Thank you.

1 Answer 1

3

You need to put general javascript in a container to include it in a specific Meteor template.

For general onLoad scripts that you might be used to, you can encapsulate that code inside a function once the template is rendered Example:

Template.*templatename*.rendered = function()
{
    //do this only on template load
    if(!this._rendered) {this._rendered = true;console.log('Template onLoad');}
    //everything outside if is done every time the template is re-drawn (meteor sends an update)
}
Sign up to request clarification or add additional context in comments.

1 Comment

I assume this templating is simply part of handlebars. If I learn Handlebars will all this be second nature ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.