PDA

View Full Version : Panel update() event



clifficious
4 Mar 2013, 4:08 AM
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:



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!

mitchellsimoens
6 Mar 2013, 7:25 AM
There is not an event but you can add a custom event:


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.