航点无限滚动以加载旧消息(向上滚动)

时间:2019-03-01 17:51:14

标签: django infinite-scroll jquery-waypoints

我正在尝试使用Waypoints无限滚动在Django中加载旧的聊天消息。我已经成功实现了正常的版本(向下滚动),但是找不到向上滚动的良好文档/ API。无限滚动中的container选项说:Default: 'auto'. Newly loaded items are appended to the container. The default value of 'auto' means the container will be the same element as the element option. The element option, in congruence with the offset option, make up the waypoint that triggers the next page to load.

那么,有没有办法在向上滚动时在旧的聊天消息前添加前缀?

这是我正常滚动(视图中使用的分页器)的代码:

<div id="itemList" class="infinite-container">
    {% for item in items %}
        <div class="infinite-item"> ........ </div>
    {% endblock %}
    {% if items.has_next %}
        <a class="infinite-more-link" href="?page={{ items.next_page_number }}"></a>
    {% endif %}
</div>


<script src="{% static 'js/waypoints/lib/jquery.waypoints.min.js' %}"></script>
<script src="{% static 'js/waypoints/lib/shortcuts/infinite.min.js' %}"></script>
 <script>
    var infinite = new Waypoint.Infinite({
      element: $('.infinite-container')[0]
    });
 </script>

0 个答案:

没有答案