2013-10-03 140 views
0

我需要顯示在我的應用程序是學生的進步卡我使用jQuery的模板,我面臨的一個問題,我有一個JSON字符串像下面jQuery的模板 - 嵌套JSON

"[{"ID":1, 
"Name":"Frank", 
"Age":15, 
"Status":"Pass", 
"MarkList":[{"year":"11/28/2012","Status":"Pass","Mark":"100"}, 
{"year":"2011","Status":"Pass","Mark":"110"}, 
{"year":"2010","Status":"Pass","Mark":"120"}, 
{"year":"2009","Status":"Pass","Mark":"130"}] 
}]" 

我給嘗試下面的代碼

{{each(i,item) $data}} 
{{each(j,subItem) $item}} 
<div>${year}</div> 
<div>${Status}</div> 
<div>${Mark}</div> 
{{/each}} 
{{/each}} 

,但不加載,我知道我的代碼是不正確的,但我不知道如何糾正...任何思想的頁面????

回答

1

要遍歷項目,然後標記列表中,你可能會想是這樣的:

{{each(i, person) $data}} 
<div>${Name}</div> 
<ul> 
    {{each(j, list) MarkList}} 
    <li>${year}</li>  
    {{/each}} 
</ul> 
{{/each}} 

樣品:http://jsfiddle.net/K8rsR/