steffenk
24 May 2010, 2:50 PM
Ext version tested:
Ext 3.2.1
Adapter used:
ext
Problem: Using defaults in a FormPanel applys the defaults, but scope get lost.
With this example, this is always the window instance, but not the Panel as expected.
defaults: {
xtype: 'checkbox',
checked: true,
listeners: {
check: function(checkbox, state) {
console.log(this); // <== this is the window but not the FormPanel
},
scope: this // <== this get lost
}
}
Example:
run this in FB console:
new Ext.Window({
title: 'Scope in Defaults',
width: 300,
height: 200,
layout: 'form',
bodyStyle:'padding:5px 5px 0',
defaults: {
xtype: 'checkbox',
checked: true,
listeners: {
check: function(checkbox, state) {
console.log(this); // <== this is the window but not the FormPanel
},
scope: this // <== this get loosed
}
},
items: [
{fieldLabel: 'Checkbox 1'},
{fieldLabel: 'Checkbox 2'},
{fieldLabel: 'Checkbox 3'},
{fieldLabel: 'Checkbox 4'},
{fieldLabel: 'Checkbox 5'}
]
}).show();
Ext 3.2.1
Adapter used:
ext
Problem: Using defaults in a FormPanel applys the defaults, but scope get lost.
With this example, this is always the window instance, but not the Panel as expected.
defaults: {
xtype: 'checkbox',
checked: true,
listeners: {
check: function(checkbox, state) {
console.log(this); // <== this is the window but not the FormPanel
},
scope: this // <== this get lost
}
}
Example:
run this in FB console:
new Ext.Window({
title: 'Scope in Defaults',
width: 300,
height: 200,
layout: 'form',
bodyStyle:'padding:5px 5px 0',
defaults: {
xtype: 'checkbox',
checked: true,
listeners: {
check: function(checkbox, state) {
console.log(this); // <== this is the window but not the FormPanel
},
scope: this // <== this get loosed
}
},
items: [
{fieldLabel: 'Checkbox 1'},
{fieldLabel: 'Checkbox 2'},
{fieldLabel: 'Checkbox 3'},
{fieldLabel: 'Checkbox 4'},
{fieldLabel: 'Checkbox 5'}
]
}).show();