Results 1 to 2 of 2

Thread: Panel update() event

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    124
    Answers
    3
    Vote Rating
    3
      0  

    Post 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      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 @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

Tags for this Thread

Posting Permissions

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