PDA

View Full Version : template applyied to carousel



ueilat
8 Aug 2010, 3:11 PM
I would use an array to generate a carousel?

supposing to have an array

[{"card":"foo1"},{"card":"foo2"},{"card":"foo3"},{"card":"foo4"}
I would generate a carousel using .update

the carousel should have the cards corresponding to this setup:


items: [{
html: 'foo1'
}, {
html: 'foo2'
}, {
html: 'foo3'
}, {
html: 'foo4'
}]

evant
8 Aug 2010, 8:11 PM
If I understand correctly:



var items = [];
Ext.each(myItems, function(item){
items.push({
html: item.card
});
});

// ....
new Ext.Panel({
items: items
});

ueilat
8 Aug 2010, 10:27 PM
Quote near
Suppose that I create my panel with a static code like

new Ext.Panel ({ ........
Items .......
});


And after an Ajax/json call I have an array with new values for populate new cards.
I asked about template, because I should make some operations on field.
So which is the best way?
Now I do in this way

var x1l=null;
var ximg=null;
for (xil in memoria[1].dati.primopiano) {
x1l=memoria[1].dati.primopiano[xil];
ximg=(x1l.foto=='')? '':'<img align=left src="' + x1l.foto + '">';
memoria[1].dati.primopiano[xil]={html: '<div class=contscorrhome><a class=testo1 href="javascript:chiama(2,' + x1l.idnotizia + ')">' + ximg + '<b>' + x1l.titolo + '</b><br/> ' + x1l.descrizione + '</a></div>'};
}

//update carousel ( no items defined).
blocchi[3].add(memoria[genpaginap1].dati["altrenews"]);
blocchi[3].doLayout();