Search code examples
sencha-touchsencha-touch-2

Sencha Touch 2 event: painted vs show?


I have a question regarding the show event. in my application I'm handling the painted event of my panel like this:

Ext.define('mvcTest.controller.Test', {
    extend: 'Ext.app.Controller',
    config: {
    refs: {
            panel: '#testpanel'
    },
    control:{
                panel: {
                    painted: 'onPainted'        
                }
        }
    },
    onPainted: function(){
        alert('painted');
    }
});

the docu say's, that there is also a "show" event, but it get not fired at all:

Ext.define('mvcTest.controller.Test', {
    extend: 'Ext.app.Controller',
    config: {
    refs: {
            panel: '#testpanel'
    },
    control:{
                panel: {
                    show: 'onShow'        
                }
        }
    },
    onShow: function(comp, obj){
        alert('show');
    }
});

why this does not work? i know, alerting is the wrong way, but that's not the question. thanks, mike


Solution

  • It seems that there's no mistake in your controller. The key reason may lie in another part of your application but ... ok, according to my experience:

    • painted event straight-forward. Everytime your view is really rendered on the screen, painted fired up. (Note: painted event fires BEFORE the child components of your view are totally rendered. In another word, painted first, DOM generation second.)

    • show event does NOT necessarily fire up, especially for the initialization time of your view. show event is something fired up when you firstly somehow hide your view, and show it later.

    Just experience, may be variant. But hope it might be helpful for you.