Last active
December 15, 2015 08:46
-
-
Save winwu/1649ede070be2903c254 to your computer and use it in GitHub Desktop.
meteor scrolltop when page onload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Source from https://github.com/tmeasday/meteor-router/issues/71#issuecomment-51592305 START */ | |
Router._filters = { | |
resetScroll: function () { | |
var scrollTo = window.currentScroll || 0; | |
$('body').scrollTop(scrollTo); | |
$('body').css("min-height", 0); | |
} | |
}; | |
var filters = Router._filters; | |
if(Meteor.isClient) { | |
Router.onAfterAction(filters.resetScroll); // for all pages | |
} | |
/* Source from https://github.com/tmeasday/meteor-router/issues/71#issuecomment-51592305 END */ | |
// if you got 404... | |
Router.configure({ | |
layoutTemplate: 'loginLayout', | |
notFoundTemplate: '404' | |
}); | |
// your customer router~ | |
Router.route('/', function () { | |
this.layout('loginLayout'); | |
this.render("login"); | |
}); | |
Router.route('/login', function () { | |
this.layout('loginLayout'); | |
this.render("login"); | |
}); | |
Router.route('/dashboard', function () { | |
this.layout('mainLayout'); | |
this.render("dashBoard"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment