PDA

View Full Version : Best method to adress lazy elements (without Ext.get...)



ImShogun
13 Aug 2009, 1:36 AM
In this (http://extjs.com/forum/showthread.php?t=35959)thread, I found a solution to submit a form who was not created using "XXX = new Ext.FormPanel(..." , It is true that if you have a simple form, button.ownerCt.submit(); works.

But in a more general approach, so it not only applies to this specific "form submit" issue but to every issue for which there is an Ext.get involved. how are we supposed to replace this:

MyObj = new Ext.formPanel(...

Ext.get('MyObj').getForm().submit()

...when we encouter this:

items:[{xtype:'form',
id:'MyObj'...

Ext.???('MyObj').getForm().submit();

Thank you for your help!

danh2000
13 Aug 2009, 1:41 AM
Ext.getCmp

hendricd
13 Aug 2009, 3:12 AM
In this (http://extjs.com/forum/showthread.php?t=35959)thread, I found a solution to submit a form who was not created using "XXX = new Ext.FormPanel(..." , It is true that if you have a simple form, button.ownerCt.submit(); works.

But in a more general approach, so it not only applies to this specific "form submit" issue but to every issue for which there is an Ext.get involved. how are we supposed to replace this:

MyObj = new Ext.formPanel(...

Ext.get('MyObj').getForm().submit()

...when we encouter this:

items:[{xtype:'form',
id:'MyObj'...

Ext.???('MyObj').getForm().submit();

Thank you for your help!

@ImShogun -- Not sure whether you're more concerned about when the FormPanel is rendered and able to post, or just accessing it, or both. But in Ext 3, the ref property makes this easier:



{
xtype: 'panel', //the container (could be anything)
items:[{
xtype:'form',
ref : '../submitable'
id:'MyObj',
items : [ ..... ],
}],
listeners : {
afterrender : function(){ //submit as soon as things are rendered
this.submitable.getForm().submit();
}

}
}

Using the ref property, you don't even need to use Ext.get[Anything](). ;)

Animal
13 Aug 2009, 3:13 AM
This whole "lazy" thing is a canard.

As soon as a {xtype: 'foo'} is added to any Container, it is instantiated into whatever type of Component it should be.

ImShogun
13 Aug 2009, 8:44 AM
@ImShogun -- Not sure whether you're more concerned about when the FormPanel is rendered and able to post, or just accessing it, or both. But in Ext 3, the ref property makes this easier:



{
xtype: 'panel', //the container (could be anything)
items:[{
xtype:'form',
ref : '../submitable'
id:'MyObj',
items : [ ..... ],
}],
listeners : {
afterrender : function(){ //submit as soon as things are rendered
this.submitable.getForm().submit();
}

}
}

Using the ref property, you don't even need to use Ext.get[Anything](). ;)

Indeed a very insteresting tip, thank you!!