I am using Sharepoint developper. Inside the page I have custom JQuery code which works fine. But when I add the $(window).scroll it does not fire.
function TTNListScroll()
{
var bestaatDiv = document.getElementById("header-fixed");
if(bestaatDiv ==null){
alert("mag maar 1 keer komen");
var head = document.getElementsByTagName("thead");
TTNmyTable = head[0].parentNode;
TTNmyTable.id="table-1";
var parent = TTNmyTable.parentNode;
parent.removeChild(TTNmyTable);
parent.appendChild(TTNmyTable);
var newTable=document.createElement("table");
newTable.id="header-fixed";
parent.appendChild(newTable);
var tableOffset = $("#table-1").offset().top;
var $header = $("#table-1 > thead").clone();
var $fixedHeader = $("#header-fixed").append($header);
$(window).scroll(function() {
alert('a');
});
alert($._data(window).events.scroll);
alert($(window).height());
}
}
The function is defined inside the document.ready My goal is to freeze a table header when i scroll down.
If anybody has any ideas they are well appreciated.
Thanks
Does TTNListScroll
get called? You define the function, but it appears you dont call it so the event wont get binded.
Alternatively, try to bind the scroll event to the 'html, body'
instead of window
, like so:
$('html, body').scroll(function() { ... });
And last but not least, you could try to bind the different scroll events directly. jQuery should take care of this, but maybe it does not correctly:
$('html, body').bind('DOMMouseScroll MouseScrollEvent MozMousePixelScroll wheel scroll', function() { your code });