Share the post "How To Dynamically Add Items To Ext.carousel.Carousel In Sencha Touch"
Suppose your code for adding items to a Ext.carousel.Carousel in Sencha Touch looks like this
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Ext.create('Ext.Carousel', { fullscreen: true, items: [ { html : 'Item 1', }, { html : 'Item 2', }, { html : 'Item 3' } ] }); |
To add these same data dynamically, place the code within its initialize function and do your looping there. Check out this sample code.
|
1 2 3 4 5 6 7 8 |
Ext.create('Ext.Carousel', { fullscreen: true, initialize: function() { for (i=1; i<=3; i++) { this.add({ html : 'Item ' + i }); } } }); |