2014-01-06 26 views
-1

我是django的新手,我確信有更好的方法來傳遞變量。我有一個從twitter bootstrap下拉對象,我希望將值傳遞給Python,以便它可以查詢不同的數據並將其顯示在頁面上。基本上,我正在尋找動態的圖表 這是我的嘗試,但它會導致頁面重新加載,這不是我想要的東西在twitter-bootstrap中傳遞變量而無需重新加載頁面

<div class="btn-group"> 
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 
    Graphs <span class="caret"></span> 
    </button> 
    <ul class="dropdown-menu" role="menu"> 
    <li><a role="menuitem" href="{% url 'ins_graph' 0 %}">graph 1</a></li> 
    <li><a role="menuitem" href="{% url 'ins_graph' 1 %}">graph 2</a></li> 
    <li class="divider"></li> 
    <li><a href="{% url 'ins_graph' 3 %}">graph 3</a></li> 
    </ul> 
</div> 

我使用谷歌圖表API來顯示數據。在普通香草django中,我也遇到了下拉菜單的問題,這個問題可能有助於澄清,因爲它有更多的細節here

回答

2

看起來好像你在尋找Ajax調用。要更改頁面上的內容而不重新加載,您需要編碼javascript。

關於它的更多信息:http://api.jquery.com/jquery.ajax/ jQuery是引導程序依賴項。

乾杯

+0

沒有經驗,任何示例代碼建議如何做到這一點,以啓動我的soulsearching與此? – rodling

相關問題