Executing onAfterRoute event on first visit


#1

The event executes when I click on a link to navigate to that particular page but not when I go directly to that page. How can I make it execute the code in both cases?

Thanks


#2

Can you post an example


#3

I want to execute the setDefaultCSS for every page I visit. This code will only work if I navigate from one page and click to navigate to a different page.
Thanks

if (Meteor.isClient) {
setDefaultCSS = function() {
switch(Router.current().route.getName()) {
case “home”:
//this page handles the movement of the footer
break;
default:
$("#footer").css(“top”, getBottomOfElement($(".nav")));
}
}

Router.onAfterAction(setDefaultCSS);

}


#4

What you should do is when your template is rendered run your animation function like so

Template.bottomNav.onRendered(function () {
  var instance = this;
  instance.$('#footer').velocity("transition.slideUpBigIn");
});

if you would like to do full page animation a great package to use would be https://github.com/ccorcos/meteor-transitioner


#5

I do not think I have made it clear what I am trying to achieve. I’ve opened a new thread to try and find the problem elsewhere. Thanks