0
Ajax響應:下拉列表
case 1:[{"id":1,"value":"sub 1"},{"id":2,"value":"sub 2"},{"id":3,"value":"sub 3"}]
case 2:[{"id":1,"value":"sub 1"},{"id":2,"value":"sub 2"},{"id":3,"value":"sub 3"}]
鬍子模板:
<div class="form-group" id="submenu_list">
<script id="dropDownList" type="text/template">
<select class="form-control" name="sub_menu" id="sub_menu" >
{{#.}}
<option value="{{id}}">{{value}}</option>
{{/.}}
</select>
</script>
</div>
鬍子渲染代碼:
var template = $("#dropDownList").html();
subMenuList = Mustache.render(template, data);
$("#submenu_list").html(subMenuList);
我正在上的另一點擊上面的響應下拉並試圖從JSON響應填充上述下拉菜單,但它不工作!請告訴我我錯在哪裏?在
<div class="form-group" id="submenu_list"></div>
內