1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    India
    Posts
    87
    Vote Rating
    0
    Ronits is on a distinguished road

      0  

    Default Answered: xtype:image handling of click event in controller

    Answered: xtype:image handling of click event in controller


    Hi,
    Would like to have click event on xtype:'image' component. Partially solved using :
    Code:
    render: function(c) {			 c.getEl().on('click', function(e) {
    			      Ext.Msg.alert('Pref Settings handler');
    			            		      }, c);
    			            		   }
    HGowever, would like to handle this event in Controller. Something like :
    Code:
    this.control({
    'image[id=preferenceSettingBtnId]': {
    				click: this.onPreferenceSettingBtnClick
    }
    But, this won't work. Any help.
    Thanks,
    Ronz

  2. I would create an Img extension to handle this:

    Code:
    Ext.define('Ux.Img', {
        extend : 'Ext.Img',
        xtype  : 'ux-img',
    
        onRender : function() {
            this.callParent(arguments);
    
            this.imgEl.on('click', this.onClick, this);
        },
    
        onClick : function(e, t) {
            this.fireEvent('click', this, e, t);
        }
    });

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,649
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    I would create an Img extension to handle this:

    Code:
    Ext.define('Ux.Img', {
        extend : 'Ext.Img',
        xtype  : 'ux-img',
    
        onRender : function() {
            this.callParent(arguments);
    
            this.imgEl.on('click', this.onClick, this);
        },
    
        onClick : function(e, t) {
            this.fireEvent('click', this, e, t);
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

  4. #3
    Sencha User
    Join Date
    Jul 2012
    Location
    India
    Posts
    87
    Vote Rating
    0
    Ronits is on a distinguished road

      0  

    Default


    Ok. Got it.
    Thanks,
    Ronz