Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sencha Touch add dynamically items

Tags:

sencha-touch

How can I add dynamically an new item in Ext.panel ? This is the code I'm using;

app.views.ViewItem = Ext.extend(Ext.Panel, {
    id: '0',
    dockedItems: [{
        xtype: 'toolbar',
        title: 'Melvin test',
        items: [
            {
                text: 'Terug',
                ui: 'back',
                listeners: {
                    'tap': function () {
                        Ext.dispatch({
                            controller: app.controllers.appController,
                            action: 'backToRssList',
                            animation: {type:'slide', direction:'right'}
                        });
                    }
                }
            },
            {xtype:'spacer'},
            {
                id: 'share',
                text: 'Delen',
                ui: 'action',
                listeners: {
                    'tap': function () {
                        Ext.dispatch({
                            controller: app.controllers.appController,
                            action: 'share',
                        });
                    }
                }
            }
        ]
    }],
    items: [],
    initComponent: function() { 
        app.views.ViewItem.superclass.initComponent.apply(this, arguments); 
    },
    getView: function(data) {
        //this.items.add({html: 'test'});
    },
});

In the function getView I am trying to add an new item with this line;

this.items.add({html: 'test'});

The error that is showing up ( in Rockmelt, Chrome ) is;

Uncaught TypeError: Object #<Object> has no method 'getItemId'

Obviously this isn't working, what am I doing wrong?

like image 232
Melvin Avatar asked Apr 13 '11 22:04

Melvin


1 Answers

Did you try using the add() function for the panel itself? E.g:

this.add({html: 'test'});
like image 102
Nicodemuz Avatar answered Oct 07 '22 22:10

Nicodemuz