-
4 Mar 2013 4:08 AM #1
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:
Thanks for any help or hints!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); }, });
-
Best Answer Posted by mitchellsimoens
There is not an event but you can add a custom event:
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.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); } });
-
6 Mar 2013 7:25 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
There is not an event but you can add a custom event:
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.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); } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote