View Full Version : Dynamically createing items

4 Jul 2011, 7:26 AM
Hi i am trying to add items to a list but the names of the list items come from an array which has a variable size, i therefore need to get the size of the array and create the list based on the size.

this is the array

var myArray = getListItems();

this is the list , between the two h2 tags is were i want to put the values from the array

items:[ {text:'<h2>ARRAYITEM</h2>', tpl:'<div class=\"contact\">{text}</div>' }]

i tried to do something like this

for(var i=0;i<myArray.length;i++)
{text:'<h2>ARRAYITEM</h2>', tpl:'<div class=\"contact\">{text}</div>' }

but this doesnt work

any help is much appreciated


Hanni Sullivan
4 Jul 2011, 11:09 PM
Oh noes, you're doing it wrong. :D

I won't write the necessary code for you, but I'll give you a hint: Check out the getting started guide (http://dev.sencha.com/deploy/touch/getting-started.html) which explains amongst a bunch of other topics the template mechanism. Look for the '<tpl for=".">' thingy.