Let’s say I have a component, and this component needs to add an event listener to a component that does NOT exist yet, but will. Let’s say it needs to for the ‘beforerender’ event of this yet-to-be-created component.
As it is right now, without knowing how to do this in ExtJS, I would do something like this:
var wait = setInterval(function() {
var cmp = Ext.getCmp('myThing');
if (cmp) {
clearInterval(wait);
cmp.on('beforerender', function() {
// ... do something on render
});
}
}, 20);
How would I do this in Ext?
Found the answer in some random github repository this morning:
https://github.com/prettycode/Ext.exts/blob/master/Ext.latentEvent.js
Apparently, there’s a
onAvailableevent thatExt.ComponentManagerexposes. When a component is created, it makes its way throughExt.ComponentManager, andonAvailablewill let listeners know after given components have been added.