Jquery plugins are undefined in global client scope, when they are loaded from packages


#1

Hi there dear Meteor community,
I would like to ask for help, since I am facing a problem with jquery plugins being undefined.
For example this package - https://github.com/fourq/meteor-pkg-typeahead
or this package - https://github.com/sergeyt/meteor-typeahead

both should extend jquery’s selectors so you can use something like

$(".typeahead").typeahead(...)
but inside my project it just returns undefined


I tried the second’s package examples and they work. The problem is somewhere in my project environment. Please, do you have any clues what could be the cause? I don’t know maybe coffeescript or some other package could be the root of this problem?


#2

The jQuery plugin is usually defined on the template, template.$ or if you’re in a instance of a template this.$ as per the doco. So if you’re in a helper, you’d do Template.instance().$(".typahead").typeahead(...) or if you’re in the onRendered, you can just call this.$(...)