-
12 Nov 2012 3:11 AM #1
How to listen for rendering done?
How to listen for rendering done?
I have some code that adjusts layout based on the rendered html, thing is that I don't know how to listen for it. I have something along the lines of:
Then what I'm looking for is something like an after render, to listen for. I have tried painted, but it's called too early, since it doesn't necessarily have a height when added to the dom:Code:Ext.define('Project.Utilities', { scaleFonts: function(container, cssClass, maxHeight, minSize) { // loop the elements and if it's height > maxHeight then it rescales till either heigt <= maxHeight or minSize is reached } });
Only way I've managed to solve this is by setTimeouts, but I would say that this is a really ugly solution. Is there some kind of afterRender, doneRendering or similar hidden event that I can look for? If not is it possible that it will come?Code:Ext.define('Project.view.SomeList', { extend: 'Ext.List', xtype: 'someList', store: 'Whatever', config: { itemTpl: '<p class="foo">{somePropertyThatMightBeTooLong}</p>', listeners: { painted: 'fixFonts' } }, fixFonts: function(container, opts) { Coupons.Utilities.scaleFonts(container, '.foo', 18, '70%') } });
Tested in 2.0 and 2.1.Developer/Alien Technologies at Mobile Ambitions Aps, Denmark.
-
13 Nov 2012 4:26 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
You can listen for the first call of the show event. painted will happen right before it's actually inserted into the DOM
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.
-
14 Nov 2012 2:48 AM #3
Show is fired before painted in my tests, I did something along the lines of:
And my log outputs show before painted.Code:Ext.define('Project.view.SomeList', { extend: 'Ext.List', xtype: 'someList', store: 'Whatever', config: { itemTpl: '<p class="foo">{somePropertyThatMightBeTooLong}</p>', listeners: { show: 'show', painted: 'paint' } }, paint: function() { Ext.Logger.verbose('Painted'); } show: function() { Ext.Logger.verbose('Show'); }});Developer/Alien Technologies at Mobile Ambitions Aps, Denmark.


Reply With Quote