pex
27 Sep 2007, 1:50 AM
Hello!
I would like to generate a <ul> with <li> items based on JSON data. For this I thought templates to be a good candidate. The JSON data I have is in the form:
{"rows":[{"tag_id":"22","name":"GA4 Visitor"},{"tag_id":"5","name":"GLIK Mailing"},{"tag_id":"56","name":"testee"},{"tag_id":"60","name":"test777"}]}
The HTML should be like:
<ul>
<li id="22">GA4 Visitor</li>
<li id="5">GLIK Mailing</li>
...
</ul>
So I created a template as follows:
this.tagListTemplate = new Ext.Template([
'<li id={id}>{tag_name}</li>'
]);
this.tagListTemplate.compile();
My question now is, how do I populate the template with the JSON data?
I would like to generate a <ul> with <li> items based on JSON data. For this I thought templates to be a good candidate. The JSON data I have is in the form:
{"rows":[{"tag_id":"22","name":"GA4 Visitor"},{"tag_id":"5","name":"GLIK Mailing"},{"tag_id":"56","name":"testee"},{"tag_id":"60","name":"test777"}]}
The HTML should be like:
<ul>
<li id="22">GA4 Visitor</li>
<li id="5">GLIK Mailing</li>
...
</ul>
So I created a template as follows:
this.tagListTemplate = new Ext.Template([
'<li id={id}>{tag_name}</li>'
]);
this.tagListTemplate.compile();
My question now is, how do I populate the template with the JSON data?