2013-08-20 27 views
0

我正在嘗試使用Ideal Forms來創建一個新的響應式網站。我目前有一個無線電選擇器和兩個下拉選擇器。我正試圖用通過cfc查詢的數據填充選擇器。我爲此寫的jquery的工作,因爲我有另一個網站使用它,但沒有使用理想的形式。當我在新頁面上運行腳本時,一切正常,沒有錯誤出現,並且返回的數據是正確格式化的json,但列表不會出現填充。通過jquery填充理想形式選擇框獲取

這裏是形式:

<form id="form1"> 
    <div> 
     <section name="Basic Search"> 
      <div id="radioDiv"> 
       <label>Radio Buttons:</label> 
        <label><input type="radio" name="r1" id="value_1" value="1" checked />1</label> 
        <label><input type="radio" name="r1" id="value_2" value="2"/>2</label> 
        <label><input type="radio" name="r1" id="value_3" value="3"/>3</label> 
      </div> 
      <div id="selectDiv1"> 
       <label>Select 1:</label> 
       <select name="select1" id="select1"> 
        <option value="all">All</option> 
       </select> 
      </div> 
      <div id="selectDiv2"> 
       <label>Select 2:</label> 
       <select name="select2" id="select2"> 
        <option value="all">All</option> 
       </select> 
      </div> 
     </section> 
    </div> 
</form> 

這裏是jQuery的:

$.fn.populateListsBasic = function(){ 
    $.get("../cfc/mycfc.cfc",{ 
     method: "getData", 
     data: conditionGroup.filter(':checked').val() 
     },function(data){ 
      $.each(data.stuff.otherStuff1,function(key,value){ 
       $("#select1").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_1[key] + ")</option>");   
      }); 
      $.each(data.stuff.otherStuff2,function(key,value){ 
       $("#select2").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_2[key] + ")</option>"); 
      }); 
     },"json"); 
}; 

$("#form1").populateListsBasic(); 

任何幫助,將不勝感激。

回答

0

不是一個真正的Coldfusion問題,但是...... #makes從哪裏來?我沒有看到你的表單中的任何地方的id?它不應該是:

$.each(data.stuff.otherStuff2,function(key,value){ 
       $("#select2").append("<option value='" + value + "'>" + value + " (" + data.stuff.otherStuffCount_2[key] + ")</option>"); 
      }); 
+0

我同意,但有人問它被標記的ColdFusion,那人已經因爲刪除了評論。 –

+0

Rob ...這是#makes id的問題嗎? –

+0

在我將其刪除出實際標識符之前,我是腳本的一部分。當我在這裏發帖時,我通常會重命名代碼,我錯過了那一個。 –