Jez D
Jez D

Reputation: 1489

Sencha: How do I add items to carousel using array

I have an array created like this: var thecharts = new Array(chartg, chartb);

In my view I have a carousel and the items of the carousel will be determined by the array thecharts
The code looks like this:

items: [
                {
                xtype: 'carousel',
                width: '90%',
                height: '70%',
            defaults: {
                styleHtmlContent:true,
                id: 'carousel'
            },

            items: [
                thecharts[0],
                thecharts[1]

            ]
        },

This works fine like this. However, the size of the array may change depending on other criteria. Therefore, I would rather not use the index and just drop the entire array into items and have it look like this:

items: [ thecharts ]

I tried it that way, but it just returned the first element in the array. How do I get it to return all elements in the array?

Upvotes: 0

Views: 117

Answers (1)

rixo
rixo

Reputation: 25001

What about this?

items: thecharts

Upvotes: 1

Related Questions