read write JSON in ExtJS
Question
I have below javascript object handy with me. I want to read it and display on HTML page.
var info={
"name":"Christina",
"age":25;
"city":"Chicago",
"post":"CMO"
};
I want to display above information with ExtJS api.
<ul>
<li>Name is ...Christina </li>
<li>Age is ... 25</li>
<li>City is ... Chicago</li>
<li>Post is ... CMO</li>
</ul>
Thanks in advance !
Solution
There is Ext.Template class for this purpose. The code should be like
var t = new Ext.Template([
'<ul>',
'<li>{name}</li>',
'<li>{age}</li>',
'<li>{city}</li>',
'<li>{post}</li>',
'</ul>'
]);
t.compile();
t.append('some-element', info);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow