Vulcan/client/body.js

23 lines
705 B
JavaScript
Raw Normal View History

2012-09-20 10:30:55 +10:00
Template.body.events({
'click a[href]': function(event) {
// intercept all link clicks and redirect them through the router
2012-09-20 10:30:55 +10:00
var url = $(event.target).closest('a').attr('href').replace(/#.*$/, '');
if (url && url[0] === '/' && url !== document.location.href) {
2012-10-17 17:25:10 +09:00
event.preventDefault();
Router.navigate(url, {trigger: true});
$('body').removeClass('mobile-nav-open');
2012-09-20 10:30:55 +10:00
}
}
});
Template.body.created = function(){
Session.set('currentScroll', null);
}
Template.body.rendered = function(){
if(currentScroll=Session.get('currentScroll')){
console.log(currentScroll);
$('body').scrollTop(currentScroll);
Session.set('currentScroll', null);
}
}