2012-12-18 100 views
0

我试图创建一个类似于到Twitter/Facebook的/ Google文档的无限滚动。我已经看过很多插件和教程,但我似乎无法弄清楚如何去做。似乎我看到的所有内容都是通过ajax加载另一个页面,而不是只从数据库中提取一部分内容。延迟加载/无限滚动和Django

 <div class="question"> 
      {% if the_question %} 
       <ul> 
       <li> 
        <div class="votecounter"> 
         <span class="score" id="linkscore{{ question_id }}" 
         title="after {{ score.num_votes|default:0 }} vote{{ score.num_votes|default:0|pluralize }}"> 
         {{ score.score|default:0 }} 
         </span> 
        </div> 
        <div class="votearrowdiv"> 
         <form class="linkvote" id="linkup{{ question.id }}" action="/home/{{ question.id }}/{% if vote and vote.is_upvote %}clear{% else %}up{% endif %}/vote/" method="POST"> 
          {% csrf_token %} 
          <input type="image" id="linkuparrow{{ question.id }}" class="{% if vote and vote.is_upvote %}uparrowBlue{% else %}uparrow{% endif %}" value=""></input> 
         </form> 
         <form class="linkvote" id="linkdown{{ question.id }}" action="/home/{{ question.id }}/{% if vote and vote.is_downvote %}clear{% else %}down{% endif %}/vote/" method="POST"> 
          {% csrf_token %} 
          <input type="image" id="linkdownarrow{{ question.id }}" class="{% if vote and vote.is_downvote %}downarrowBlue{% else %}downarrow{% endif %}" value=""></input> 
         </form> 
        </div> 
         <div class="actualQuestion"> 
         <a href="/home/{{ content.id }}/{{ question.id }}/">{{ question.question_text }}</a> 
         </div> 
       </li> 
       </ul> 
      </div> 

在此先感谢!

+0

如果通过AJAX加载另一个页面(实际上是另一个页面的一部分)是不是你想要的,又是什么?通常通过ajax一次获取内容片段被认为是“仅从数据库中提取一部分内容”。另一个选择是获取一个json响应,并用该信息客户端扩充一个模板,但这也是ajax。哪部分过程令人反感? –

回答