无尽的分页卡在show_more上

时间:2013-11-25 12:08:48

标签: ajax django django-endless-pagination

所以我试图在我的项目中使用ajax实现Twitter风格的分页,但是当我点击show_more时它会卡住。它只是更改为标签“加载”,并不显示任何新条目。 views.py

def view_dates(request, check, template = 'dates.html',page_template = 'dates_table.html'):
    check = Check.objects.get(id = check) 
    dates = Date.objects.filter(check_id = check).order_by('-date').select_related('check').annotate(status = Min('result__status'))
    context = {
    'dates': dates,
    'check': check,
    'page_template': page_template}
    if request.is_ajax():
        template = page_template
    return render_to_response(template, context, context_instance=RequestContext(request))  

dates.html

{% paginate 16 dates %}
<br>
<table class = 'table table-hover'>
        <tr>
            <td>Date</td>
            <td>Status</td>
            <td></td>
        </tr>

<div class="endless_page_template">
    {% include page_template %}
</div>

</table>
{% show_more %}
</body>
{% block js %}
  {{ block.super }}
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" src="http://yourjavascript.com/337923491/endless.js" charset="utf-8"></script>
  <script type="text/javascript" src="http://yourjavascript.com/151379951/endless-pagination.js"></script>
  <script>
    $.endlessPaginate({paginateOnScroll: true,
    endless_on_scroll_margin : 10,
    paginateOnScrollChunkSize: 5        
});</script>
{% endblock %}

page_template - dates_table.html

{% load date_extras %}
{% block table %}
        {% for date in dates %}
            <tr>
                <td>
                    <button type="button" class="btn btn-link" onclick="location.href='/checks/{{ date.check_id }}/{{ date.id }}/results/'">
                        {{ date.date|format }}
                    </button>
                    </td>
                <td>
                    {% if date.status == True %}
                            <span class="glyphicon glyphicon-ok"></span>
                        {% else %}
                            <span class="glyphicon glyphicon-remove"></span>
                    {% endif %}
                </td>
                <td><a href='/checks/{{ date.check_id }}/{{ date.id }}/delete/'><span class="glyphicon glyphicon-trash"></span></a>
                </td>
            </tr>       
        {% endfor %}
    </table>
{% endblock %}

应该是什么问题?

1 个答案:

答案 0 :(得分:0)

您应该在show_more中添加page_template按钮,而不是在索引模板中...