links. I currently provide the same entry...">

Event handler for all templates?

I would like to install an event handler to handle all <a class="nav" /> links. I currently provide the same entry for event cards in almost every template. Therefore, I get entries like

 Template.XXX.events = { 'click a.nav' : linkCallback } 

everywhere. Is there a way to install event handlers around the world? I could not find a way when looking at the documentation , but tmeasdays meteor -router seems to be able to do this. I just can't figure out how.

+4
source share
1 answer

Just create a template that wraps each other template and attaches events to it:

 <body> {{> body}} </body> <template name="body"> </template> Template.body.events = function() { 'click .nav': linkCallback } 
+12
source

All Articles