PDA

View Full Version : onLaunch in controller not working



arshabh.clarice
3 Nov 2012, 1:14 PM
below is my code for controller class



Ext.define('MyApp.controller.Main', {
extend: 'Ext.app.Controller',



models: [
'Leave'
],
stores: [
'MyJsonStore'
],
views: [
'Login',
'MyViewport',
'ManageColumn'
],










onLaunch:function(){

Ext.get('edit').on('click',function(){
console.log('clicked');
});

},




allowEdit:function(){
console.log('hello');

}

});


the onLaunch is not working as expected,
i get the following error

Cannot call method 'on' of null

the documentation states that it is called after the launch function of application is executed. But the click event is not getting attached to my element.

once i go to my browser and type Ext.get('edit')
i get a object to which i can attach click event easily,
where am i wrong?? please help

vietits
3 Nov 2012, 3:05 PM
You should wait for components to finish their rendering before referring to them.