Results 1 to 2 of 2

Thread: onLaunch in controller not working

  1. #1

    Default onLaunch in controller not working

    below is my code for controller class

    Code:
    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

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347

    Default

    You should wait for components to finish their rendering before referring to them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •