PDA

View Full Version : When to use (or not) renderTo: document.body



dr-dan
4 Oct 2012, 1:22 AM
I am confused (nothing new there then).

When the following code is in my Ext.applications's launch() override, the form displays correctly


Ext.create('Pegfect.view.profile.LoginForm', {
renderTo: document.body
});

However, when it is in a controller's code, it does not, and no error is reported:

Am I breaking some unwritten Ext JS law here?

controller snippet:


init: function () {
this.onApplicationLoaded();
}

onApplicationLoaded : function () {
Ext.create('Pegfect.view.profile.LoginForm', {
renderTo: document.body
});
}


Or is it more to do with pipeline (sometimes i feel im forever stuck in some asp.net web forms style init, load, render order-of-things-horror-nightmare).

skirtle
4 Oct 2012, 2:15 AM
All sorts of things that could be going wrong here. Try this:


onApplicationLoaded : function () {
console.log(document.body);

Ext.create('Pegfect.view.profile.LoginForm', {
renderTo: document.body
});
}

This will confirm two things: whether the method is being called and whether or not document.body exists at that point.