I'm trying to change the section height after the page loads but it doesn't always work. I know my code to change the height is fine, and it works on window resize, just the initial call after document.ready doesn't always work.
var $window = $(window);
function wrap_element_link_mobile(object, path) {
if ($(this).width() < 921 && !object.parent().is('a')) {
object.wrap("<a href='" + path + "'></a>");
} else if ($(this).width() > 920 && object.parent().is('a')) {
object.unwrap();
}
}
function resize_section() {
var sectionMinHeight = $(window).height() - $('header').height() - $('footer').height() - 7;
$('section').css('min-height', sectionMinHeight);
}
/* Called after document Load
================================ */
$(document).ready(function () {
var $mainLogo = $('#main-logo');
wrap_element_link_mobile($mainLogo, '/');
resize_section();
$window.resize(function () {
wrap_element_link_mobile($mainLogo, '/');
resize_section();
});
});
After creating a console.log in the initial call I figured out it is getting called but for some reason it's not working.
*Edit screen of what I see
Notice the scroll bar, it goes away if I resize the window at all though and is the proper height.
})
– RachelrachelesectionMinHeight
inresize_section()
when it fires? I suspect you are loading images in the header which not not be fully loaded when the DOM is ready. If any images you should set the dimension explicitly. – Emilio$(document).ready()
– Emiliodata-no-turbolink
attribute on the body tag) – Foregather