MrBeef
5 May 2012, 11:42 AM
Hi everyone,
I'm using an Ext.Ajax.request to dynamically load the 'selectfield' options on an Ext.form.Panel.
I realized that declaring variables inside of the AJAX request would not work due to the variable scope, so I declared them outside. However, when I populate my form, I still see that the field's text and value are 'undefined'. I'd appreciate any advice, thanks!
var candidate;
var opponent;
Ext.Ajax.request({
url: 'get_info.php',
success: function(response){
data = Ext.JSON.decode(response.responseText)
candidate = data.candidate;
opponent = data.opponent;
}
});
Ext.getCmp('fieldset').add([
{
xtype: 'selectfield',
name : 'c_choice',
id : 'c_choice',
label: 'Choice?',
options: [
{text: candidate, value: candidate},
{text: opponent, value: opponent}
]
}
]);
I'm using an Ext.Ajax.request to dynamically load the 'selectfield' options on an Ext.form.Panel.
I realized that declaring variables inside of the AJAX request would not work due to the variable scope, so I declared them outside. However, when I populate my form, I still see that the field's text and value are 'undefined'. I'd appreciate any advice, thanks!
var candidate;
var opponent;
Ext.Ajax.request({
url: 'get_info.php',
success: function(response){
data = Ext.JSON.decode(response.responseText)
candidate = data.candidate;
opponent = data.opponent;
}
});
Ext.getCmp('fieldset').add([
{
xtype: 'selectfield',
name : 'c_choice',
id : 'c_choice',
label: 'Choice?',
options: [
{text: candidate, value: candidate},
{text: opponent, value: opponent}
]
}
]);