开发者

Jquery scroll hits twice on IE

开发者 https://www.devze.com 2022-12-17 05:50 出处:网络
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.

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 
     }
 }

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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消