Search code examples
sencha-touch-2

Sencha Touch 2 painted event not firing


I built a view and I want to do some manipulation of the elements, after the view has been painted.

I am trying to use the "painted" event with no avail.

Any ideas why?

Ext.define('TestApp.view.phone.RegisterViewPhone', {

    extend: 'Ext.Panel',

    xtype: 'RegisterViewPhone',

    config: {

        items: [
            {
                xtype: 'Header'
            },{
                xtype: 'panel',
                itemId: 'thePanel',
                html: 'THIS WILL HOLD THE VIEWS CONTENT'
            },{
                xtype: 'Footer'
            }
        ],

        listeners: [
            {
                delegate: '#thePanel',
                event: 'painted',
                fn: 'onPainted'
            }
        ]
    },
    onPainted: function () {
        alert('hey!');
    }
});

Solution

  • You can attach listeners to that particular element like

       {
            xtype: 'panel',
            itemId: 'thePanel',
            html: 'THIS WILL HOLD THE VIEWS CONTENT',
            listeners: {
                painted: function(){
                    alert('hey!');
                }
            }
        }
    

    As painted is not dependent on individual element and it acts on page scope also U can write it in views directly

    items: [
     ],
     listeners: {
     painted: function () {  
       alert('hey!');
     }