Results 1 to 3 of 3

Thread: How to add a listener on controller

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    14
    Vote Rating
    0
      0  

    Default Unanswered: How to add a listener on controller

    Hi everyone.

    I have this controller.

    Code:
    Ext.define('deportes.controller.Controlador', {
        extend: 'Ext.app.Controller',
        views: ['HomePage', 'BuscadorEquipos'],
        //stores: ['Selectores'],
    
    
        refs: [
               {
                   ref: 'addFav',
                   selector: '#addFav'
               }
           ],
    
    
        init: function() {    
            this.control({
                '#addFav': {
                    'itemtap': function(){
                        //this.addTeamFavorites;
                        Ext.Viewport.setActiveItem({xtype:'homepage'});
                        //alert('shot');//this.addTeamFavorites
                    }
                }
            });
        }
    });

    And i want to make a behaviour when user press the id #addFav in the view "buscadorequipos". I tried to "click", "tap" and "itemtap" without any results.

    Code:
    Ext.define('deportes.view.BuscadorEquipos', {
        extend : 'Ext.form.Panel',
        alias : 'widget.buscadorequipos',
        config : {
            items: [
                    {
                        xtype: 'fieldset',
                        items: [disciplinas,modalidades,competiciones,equipos]
                    },
                    {
                        xtype: 'fieldset',
                        html: '<strong id="addFav">F</strong>'
                    }
                
                ]
        },
        initialize : function() {
            console.log("InitComponent for homepage");
            this.callParent();
        }
    });
    Can anyone help me?

    Thanks in advance.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,336
    Answers
    3885
    Vote Rating
    1296
      0  

    Default

    Using this.control() uses ComponentQuery so it can only listen for Components which DOM elements are not Components. To do this, you would have to listen for when the component is rendered via this.control() and then set a listener on that dom element.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    14
    Vote Rating
    0
      0  

    Default

    Can you show me an example please?

Posting Permissions

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