Results 1 to 3 of 3

Thread: Check Change Listener

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
      0  

    Default Check Change Listener

    What is the right way to handle menu check items events ?
    I have this menu:
    Code:
     {      xtype: 'button',  
            id: 'types_btn',  
           autoWidth: true,   
           text: 'Types',  
           menu: {        
               xtype: 'menu',   
               frame: true,        
              id: 'types_menue',     
              items: [              
             {                    
                  xtype: 'menucheckitem',           
                  id: 'f_type',                 
                  text: 'first',                  
                  listeners: {                    
                     checkchange: {                 
                         fn: me.onFirstButtoncheckchange,           
                        scope: me           
                             }                          
                }                  
         },                      
     {                   
                     xtype: 'menucheckitem',     
                      id: 's_type',           
                     text: 'second',                  
                     listeners: {                        
                           checkchange: {                 
                                  fn: me.onSecondButtoncheckchange,         
                                 scope: me                              
          }                      
                    }             
              }


    Then the functions:

    Code:
    onFirstButtoncheckchange: function(menucheckitem, checked, options) {   
     var t = Ext.getCmp('f_type');        
           if (t.checked)              
         goToFunction(???);            
            .        
            .    
    }, 
    
    onSecondButtoncheckchange: function(menucheckitem, checked, options) {    
    var t = Ext.getCmp('s_type');       
            if (t.checked)             
          goToFunction(???);        
             .          
            .    },


    1- Is there anyway to use one listener and gather all different functions in it ?

    2- How can I send the current item to goToFunction() as you see in the code ?

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Vote Rating
    390
      1  

    Default

    The first argument passed to the listener function is the CheckItem instance. You don't need to look it up using Ext.getCmp, you already have it.

    In general you should avoid using fixed ids and Ext.getCmp.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
      0  

    Default

    Thank you.

Tags for this Thread

Posting Permissions

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