栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

django.core.paginator使用jQuery进行Ajax分页

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

django.core.paginator使用jQuery进行Ajax分页

我没有发现错误,但下面向您展示如何解决此任务。我认为您可以轻松地使其适应您的需求。

jQuery ajax部分:

<script type="text/javascript">function ajax_get_update()    {       $.get(url, function(results){          //get the parts of the result you want to update. Just select the needed parts of the response          var table = $("table", results);          var span = $("span.step-links", results);          //update the ajax_table_result with the return value          $('#ajax_table_result').html(table);          $('.step-links').html(span);        }, "html");    }//bind the corresponding links in your document to the ajax get function$( document ).ready( function() {    $( '.step-links #prev' ).click( function(e) {        e.preventDefault();        url = ($( '.step-links #prev' )[0].href);        ajax_get_update();    });    $( '.step-links #next' ).click( function(e) {        e.preventDefault();        url = ($( '.step-links #next' )[0].href);        ajax_get_update();    });});//since the links are reloaded we have to bind the links again//to the actions$( document ).ajaxStop( function() {    $( '.step-links #prev' ).click( function(e) {        e.preventDefault();        url = ($( '.step-links #prev' )[0].href);        ajax_get_update();    });    $( '.step-links #next' ).click( function(e) {        e.preventDefault();        url = ($( '.step-links #next' )[0].href);        ajax_get_update();    });});</script>

模板html部分:

<div > <span >     {% if object_list.has_previous %}     <a id="prev" href="?{{ urlquerystring_previous_page }}">previous</a>     {% else %}     <span >previous</span>     {% endif %}     <span >     Page {{ object_list.number }} of {{ object_list.paginator.num_pages }}.     </span>     {% if object_list.has_next %}      <a id="next" href="?{{ urlquerystring_next_page }}">next</a>     {% else %}      <span >next</span>     {% endif %} </span>        </div> <form  id="action-selecter" action="{{ request.path }}" method="POST"> <div id="ajax_table_result">     <table  cellspacing="5">         <thead>  {% table_header headers %}         </thead>  <tbody>    ....


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/449104.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号