Jquery面板滚动到底部触发不触发

时间:2015-03-23 11:09:51

标签: c# jquery model-view-controller scroll

我正在使用MVC 4,我需要像Facebook那样的分页,当滚动到达底部时,将db的新数据集添加到现有数据中。
怎么做?
我的代码

<div class="panel-body LogPanel" style="height: 550px; overflow-x: hidden; overflow-y: auto">

<script type="text/javascript">

    $(window).scroll(function () {

        if ($(window).scrollTop() == $(document).height() - $(window).height()) {

            alert("End Of The Page");

            // run our call for pagination
        }

    });
</script>

1 个答案:

答案 0 :(得分:0)

您可以使用以下想法:

$(document).scroll(function () {
     if ($(window).scrollTop() + $(window).height() == $(document).height()) {
        //use ajax here and check if more data are fetching or not,
        //if there are more data from this ajax call, load data here  
        //else make your loader empty
     }
});
相关问题