jQuery的滚动击中两次的IE浏览器 [英] Jquery scroll hits twice on IE

查看:96
本文介绍了jQuery的滚动击中两次的IE浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这样的code调用一个Ajax每当一个div的滚动击中结束。它的假设是自动动态滚动。此AJAX获取列表的下一个x itens

have this code that calls an ajax whenever the scroll of a div hits the end. It's suppose to be an auto-dynamic scroll. This ajax gets the next X itens of the list.

 $("#gvContacts").scroll(function(){
     var scrolltop=$('#gvContacts').attr('scrollTop');  
     var scrollheight=$('#gvContacts').attr('scrollHeight');  
     var windowheight=$('#gvContacts').attr('clientHeight');                             

     if(scrolltop==(scrollheight-(windowheight)))  
     {                                
        var p = eval($("#pageNumber").val());        
        $("#pageNumber").val(p + 1); // This updates what page should the ajax get next
        loadRelatedFilters(false); //This call an ajax to load more 
     }
 }

它工作正常在FF,Chrome浏览器...它也适用于IE浏览器。但它击中了两次,想不通。每次它击中它得到2页而不是一个。

It works fine on FF, Chrome... it also works on IE. but it hits twice, can't figure out. Everytime it hits the end of the list it gets 2 pages instead of one.

推荐答案

这听起来像你需要的去抖的滚动事件。然而,它的真正的听起来就像是你工作在一个无限滚动 - 我错了

It sounds like you need to debounce the scroll event. However, what it really sounds like is that you're working on an "infinite scroll" - am I wrong?

如果如此 - 只是用什么已经被写入! http://www.infinite-scroll.com/

If so - just use what's already been written! http://www.infinite-scroll.com/

这篇关于jQuery的滚动击中两次的IE浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆