Loading content with ajax while scrolling

后端 未结 4 1782
温柔的废话
温柔的废话 2020-12-10 23:24

I\'m using jQuery Tools Plugin as image slider (image here), but due to large amount of images I need to load them few at a time. Since it\'s javascript coded, I can\'t have

4条回答
  •  离开以前
    2020-12-10 23:58

    I just had to use jQuery Tools' API, the onSeek parameter within the scrollable() method.

    It was something like that

    $(".scrollable").scrollable({
        vertical: true,
        onSeek: function() {
            row = this.getIndex();
            // Check if it's worth to load more content
            if(row%4 == 0 && row != 0) {
                var id = this.getItems().find('img').filter(':last').attr('id');
                id = parseInt(id);
                $.get('galeria.items.php?id='+id, null, function(html) {
                    $('.items').append(html);
                });
            }
        }
    }); 
    

提交回复
热议问题