javascript - How to prevent the auto Scroll Event while loading new HTML contents? -


i using window.scroll() function appending more html contents div holder while scrolling . loading 10..10 each on each scroll event. after loading first 10 contents, document size increasing , accordingly browser automatically scrolls , calling loadcontent function , appending new contents without doing scroll manually.how can prevent mechanism.i need load further contents when user scrolls button.

$(function(){   var loading = true;   $(window).scroll(function(){   if ( loading && $(window).scrolltop() + $(window).height() > $(document).height() - 100 ){         loading = false;         loadcontents();         loading = true;  }  });  )}; 

is there other better way perform infinite scrolling functionality?

usually boolean flag you're doing how handle this. though data filled in using ajax , that's loading changed. values loading seems reverse also.

$(function(){     var loading = false;     $(window).scroll(function(){         if ( !loading && $(window).scrolltop() + $(window).height() > $(document).height() - 100 ){             loading = true;             loadcontents();         }     });      function loadcontents() {         $.ajax({             ...,             success: function () {                 // add new data                 loading = false;             }         });     } )}; 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -