I have a jQuery function to make a div stick to the top of the page, after it is scrolled below the original position. However, after a button click (postback), you have to scroll above the div first before it works again.
I think this may be the troublemaker:
MaintainScrollPositionOnPostback="true"
My jQuery:
$(document).ready(function () {
function fixedNav() {
if ($(window).scrollTop() > 150) {
$('#navigation').addClass('fixedNav');
$('#mainContent').addClass('pushedMainContent');
}
else {
$('#navigation').removeClass('fixedNav');
$('#mainContent').removeClass('pushedMainContent');
}
}
function isPostBack() {
fixedNav();
}
$(window).scroll(function () {
fixedNav();
})
})
I have been going over the function for an hour and I can't seem to find a fix. (I even added the same function to the isPostBack but that didn't help) Any help/suggestions are appreciated.
Fix: (thank you @charlietfl)
<script>see "My jQuery"</script>
<body onload="fixedNav()">