jQuery click event not working, works in console

Hey all. So I’m trying to get a altered version of this codepen: http://codepen.io/teetteet/pen/Iwaqb working in Meteor. In the pen, it uses a simple jQuery statement to toggle a class on/off on a click event. It works fine in the pen, but in app the click event doesnt seem to trigger the toggle. If i manually go into the console and enter $('.cover').toggleClass('open'); all the panels flip down as they should. Any thoughts?

Is there a more “Meteor” way to go about triggering this event?

My first thought with Meteor would be to have a Template helper return the class, but im not sure how i would go about triggering that on a click event.


I’m not sure as to how you currently have your code, but here is how I would do it.

   'click .cover': function(event, template){

Hopefully this helps any.


Nice, just what i was looking for. I’d rep ya if i could.

The Meteor way is to create events(function) for handling these click, submit etc on a page like @jrudio has mentioned

make sure your template is in client; not server. Share a bit more of your code context for more help.

Have a read here

for more info.

the event hooks are pretty powerful and easy to implement.

1 Like