2012-12-18 161 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。哪部分過程令人反感? –

回答