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 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,556
    Answers
    3931
    Vote Rating
    1272
      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! Checkout the CODE tag!

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

  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
  •