jtemplate之#foreach嵌套使用

1.首先看一下我们的json数据:

[ {"goodsId":22,"goodsSn":"111","goodsName":"ppp", "simplyGoodsSizes":[ {"id":30,"newPrice":44,"sizeStr":"4*4"}, {"id":28,"newPrice":22,"sizeStr":"2*2"} ] }, {"goodsId":22,"goodsSn":"111","goodsName":"ppp", "simplyGoodsSizes":[ {"id":32,"newPrice":123,"sizeStr":"6*6"}, {"id":258,"newPrice":456,"sizeStr":"7*7"} ] } ]



2.模板文件:



3.附件数据:
$("#goods_result_dialog").setTemplateElement("goods_result_template"); // 给模板加载数据 $("#goods_result_dialog").processTemplate(json); //

注意上面的json数据为服务器返回的json对象,格式为1中所示的数据格式.

注意上面的这一段的嵌套写法:
{#foreach $T.record.simplyGoodsSizes as goodsSize} {$T.goodsSize.sizeStr}{#/for}

【jtemplate之#foreach嵌套使用】

    推荐阅读