1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    122
    Answers
    3
    Vote Rating
    3
    clifficious is on a distinguished road

      0  

    Post Answered: Panel update() event

    Answered: Panel update() event


    Hi,

    I have a panel with an tpl content which is filled dynamically. That works fine by calling the update() method of the panel in the controller with the specific content.

    Now I want to do some more stuff when the panel is updated. Is there an event that is fired in the panel for that I can listen?

    Example Code:

    Code:
    Ext.define('MyPanel, {
        extend : 'Ext.Panel',
        alias : 'widget.myPanel',
        itemId: 'myPanel',
        listeners: {
    
            ???EVENT???: function(){
                console.log('Content changed');
            },
            scope: this
        },
    
    
        initComponent : function() {
            var me = this;
    
    
            Ext.applyIf(me, {
                tpl : new Ext.XTemplate(
                        '<h1>{name}</h1><br />' 
                        )  
            });
            me.callParent(arguments);
        },
        
    });
    Thanks for any help or hints!

  2. There is not an event but you can add a custom event:

    Code:
    Ext.define('MyPanel', {
        extend : 'Ext.Panel',
        xtype  : 'myPanel',
    
        initComponent : function () {
            var me = this;
    
            Ext.applyIf(me, {
                tpl : new Ext.XTemplate(
                    '<h1>{name}</h1><br />'
                )
            });
            me.callParent(arguments);
        },
    
        update : function(htmlOrData, loadScripts, cb) {
            this.callParent([htmlOrData, loadScripts, cb]);
            
            this.fireEvent('update', this, htmlOrData);
        }
    });
    However, if you are going to just listen for the event in the same view and not another view or controller then firing and listening to events is unneeded. Just handle it where the this.fireEvent is.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    850
    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

      0  

    Default


    There is not an event but you can add a custom event:

    Code:
    Ext.define('MyPanel', {
        extend : 'Ext.Panel',
        xtype  : 'myPanel',
    
        initComponent : function () {
            var me = this;
    
            Ext.applyIf(me, {
                tpl : new Ext.XTemplate(
                    '<h1>{name}</h1><br />'
                )
            });
            me.callParent(arguments);
        },
    
        update : function(htmlOrData, loadScripts, cb) {
            this.callParent([htmlOrData, loadScripts, cb]);
            
            this.fireEvent('update', this, htmlOrData);
        }
    });
    However, if you are going to just listen for the event in the same view and not another view or controller then firing and listening to events is unneeded. Just handle it where the this.fireEvent is.
    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.

Thread Participants: 1

Tags for this Thread