built code display value json format html output. when without sublevel works fine. per new requirement, need display "testele1, testele2" header. sub level elements checkbox label.
this present code used display single level json format html output.
html:
<div class="container"> <@ _.each(data,function(value, key, list){ @> <input id="<@= value.filtername @>" class="" type="checkbox" name="<@= value.filtername @>" value="<@= value.filtervalue @>"><label id="label-<@= value.filtername @>" for="<@= value.filtername @>"> <span class="filterlabel"><@= value.filterlabel @></span></label> <@ }); @> </div>
json:
[ "testele1":[ { filtername:'test1', filterlabel:'test1', filtervalue:'test1' }, { filtername:'test2', filterlabel:'test2', filtervalue:'test2' } ], "testele2":[ { filtername:'test3', filterlabel:'test3', filtervalue:'test3' }, { filtername:'test4', filterlabel:'test4', filtervalue:'test4' } ] ]
output (in front of test1, test2, test3, test4 have checkbox):
testele1 test1 test2 testele2 test3 test4
you json not valid .correct form
[ { "testele1":[ { "filtername":"test1", "filterlabel":"test1", "filtervalue":"test1" }, { "filtername":"test2", "filterlabel":"test2", "filtervalue":"test2" } ] }, { "testele2":[ { "filtername":"test3", "filterlabel":"test3", "filtervalue":"test3" }, { "filtername":"test4", "filterlabel":"test4", "filtervalue":"test4" } ] } ]
try code. although not sure template syntax used this.
<div class="container"> <@ _.each(data,function(val1, key1){ @> <@ _.each(val1,function(val,key){ @> <h3><@= key @></h3> // title value <@ _.each(val,function(value,index){ @> <input id="<@= value.filtername @>" class="" type="checkbox" name="<@= value.filtername @>" value="<@= value.filtervalue @>"><label id="label-<@= value.filtername @>" for="<@= value.filtername @>"> <span class="filterlabel"><@= value.filterlabel @></span></label> <@ }); @> <hr> }); }); @> </div>
Comments
Post a Comment