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 User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,062
    Answers
    3976
    Vote Rating
    1391
      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
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    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
  •