0
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if $(window).scrollTop() > $(document).height() - $(window).height() - 130
alert "to much alerts"
$('.pagination').text('Fetching more users...')
問題就像在標題中......當我向下滾動頁面時,它顯示消息x 5/10。所以代碼工作,但爲什麼它被執行很多次?jQuery警惕火災4/10次,爲什麼?
你應該在每個像素上滾動時去除在大多數瀏覽器/設備上調用的onscroll事件 – 2015-02-11 08:54:48
一旦條件成立,只要向下滾動,它就會保持爲真。所以它被執行了很多次。你需要使用標誌來限制這一點。 – 2015-02-11 09:00:47