当数据不再是codeigniter时,如何停止无限滚动

时间:2018-05-10 02:08:16

标签: codeigniter

我遇到无限滚动功能的问题,当所有内容都已显示时,它仍然继续滚动(奇怪的行为)。我正在寻找一种方法来显示所有内容时停止无限滚动

这是我的代码

    $(document).ready(function() {

        var total_record = 0;
        var total_groups = <?php echo $total_data; ?>;

        $('#results').load("<?php echo base_url() ?>admin/csr_transactions/get_products",
            {'group_no':total_record}, function() {total_record++;});

        $(window).scroll(function() { 
    });

        $('#load_more').click(function(){
            load_more(total_record, total_groups);
        });


        function load_more(total_record, total_groups) {
            if(total_record <= total_groups)
            {
                $('.loader_image').show(); 
                $.post('<?php echo site_url() ?>admin/csr_transactions/get_products',{'group_no': total_record},
                    function(data)
                    { 
                        if (data != "") {                               
                            $("#results").append(data);                 
                            $('.loader_image').hide();                  
                            total_record++;
                        }

                    });     
            }
        }





    });
</script>`

0 个答案:

没有答案