Window Scroll to hide address bar


#1

Hey guys, I’m trying to hide the address bar on mobile devices by scrolling to the top of the page. This is like 2011 web beginner type stuff I know, but it’s actually not working even if I wrap it in a window.load.

Template.MasterLayout.created = function () {
	$(function() {
	    function orientationChange(e) {
	        $("body").scrollTop(1);
	    }
	    var wH = $(window).outerHeight();
	    $("body").css({ height: "+=" + wH }).scrollTop(1);
	    $(window).bind("orientationchange", orientationChange);
	});
};

What am I not getting here? This should be super simple, right? … Right?


#2

I don’t think you don’t want to do that activity when the template is created, but rather rendered. (onRendered, not onCreated)

http://docs.meteor.com/#/full/template_onRendered

It probably isn’t working because .created isn’t the right hook anyway, its .onCreated - http://docs.meteor.com/#/full/template_onCreated