我正在调用滚动功能,当我的目的服务我解除了绑定滚动。但在菜单选项卡的点击我想再次绑定滚动。我们可以重新绑定滚动后绑定它与刷新页面。这里是我的代码。因为他们不提供一个处理函数绑定绑定/解除绑定滚动
var currentPage = 1;
var xhr = null;
var flag = 0;
(window).bind('scroll');
$(document).ready(function()
{
$('#gallery').bind("click",function()
{
flag = 0;
currentPage = 1;
alert(currentPage);
scroll()
});
});
function scroll(){ $(window).bind('scroll');}
function refresh(){flag = 1; alert("flag");}
function checkScroll() {
if (flag==1){ $(window).unbind('scroll');}
if(nearBottomOfPage() == 0)
{
currentPage ++;
xhr = $.ajax(
{
url : '/ideabank?page=' + currentPage,
beforeSend: function() {
$('#loading').show()
},
complete: function(){
$('#loading').hide()
},
success : function(){}
});
}
}
function nearBottomOfPage() {
return scrollDistanceFromBottom();
}
function scrollDistanceFromBottom(argument) {
return $(document).height() - ($(window).height() + $(window).scrollTop());
}
$(window).bind('scroll',function(){
checkScroll();
});
可能重复的[无法重新绑定滚动事件?](http://stackoverflow.com/questions/11122010/can-not-rebind-scroll-event) – 2012-07-11 06:19:56