我正在使用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>
答案 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
}
});